Merge branch 'wip' into dev

This commit is contained in:
Mike Macgirvin 2023-11-27 18:31:46 +11:00
commit 35c147dfa2
8 changed files with 56 additions and 7 deletions

View file

@ -189,7 +189,7 @@ class ActivityPub
return false; return false;
} }
$hash = random_string(); $hash = new_uuid();
logger('queue: ' . $hash . ' ' . $dest_url, LOGGER_DEBUG); logger('queue: ' . $hash . ' ' . $dest_url, LOGGER_DEBUG);
Queue::insert([ Queue::insert([

View file

@ -182,12 +182,13 @@ class Queue
$x = q( $x = q(
"insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority, "insert into outq ( outq_hash, outq_account, outq_channel, outq_mid, outq_driver, outq_posturl, outq_async, outq_priority,
outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg, outq_log ) outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg, outq_log )
values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '' )", values ( '%s', %d, %d, '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '' )",
dbesc($arr['hash']), dbesc($arr['hash']),
intval($arr['account_id']), intval($arr['account_id']),
intval($arr['channel_id']), intval($arr['channel_id']),
dbesc(($arr['mid'] ?? ''),
dbesc((isset($arr['driver']) && $arr['driver']) ? $arr['driver'] : 'nomad'), dbesc((isset($arr['driver']) && $arr['driver']) ? $arr['driver'] : 'nomad'),
dbesc($arr['posturl']), dbesc($arr['posturl']),
intval(1), intval(1),

View file

@ -84,7 +84,7 @@ class Webfinger extends Controller
} }
if ($channel_target || $site_query) { if ($channel_target || $site_query) {
$h = get_hubloc_addrs_by_hash($channel_target['channel_hash']); $h = get_locations_by_hash($channel_target['channel_hash']);
if (!isset($result['subject'])) { if (!isset($result['subject'])) {
$result['subject'] = $resource; $result['subject'] = $resource;
@ -100,6 +100,7 @@ class Webfinger extends Controller
if ($h) { if ($h) {
foreach ($h as $hh) { foreach ($h as $hh) {
$aliases[] = 'acct:' . $hh['hubloc_addr']; $aliases[] = 'acct:' . $hh['hubloc_addr'];
$aliases[] = $hh['hubloc_id_url'];
} }
} }

43
Code/Update/_1272.php Normal file
View file

@ -0,0 +1,43 @@
<?php
namespace Code\Update;
class _1272
{
public function run()
{
q("START TRANSACTION");
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE outq ADD outq_mid text NOT NULL DEFAULT '' ");
$r2 = q("create index \"outq_mid_idx\" on outq (\"outq_mid\")");
$r = ($r1 && $r2);
} else {
$r = q("ALTER TABLE `outq` ADD `outq_mid` varchar(255) NOT NULL DEFAULT '' ,
ADD INDEX `outq_mid` (`outq_mid`)");
}
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
q("ROLLBACK");
return UPDATE_FAILED;
}
public function verify()
{
$columns = db_columns('outq');
if (in_array('outq_mid', $columns)) {
return true;
}
return false;
}
}

View file

@ -26,7 +26,7 @@ use Code\Lib\Url;
*/ */
const REPOSITORY_ID = 'streams'; const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1271; const DB_UPDATE_VERSION = 1272;
const PROJECT_BASE = __DIR__; const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true; const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '12.0'; const NOMAD_PROTOCOL_VERSION = '12.0';

View file

@ -324,10 +324,10 @@ function ping_site($url)
} }
function get_hubloc_addrs_by_hash($hash) function get_locations_by_hash($hash)
{ {
return q( return q(
"select hubloc_addr from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", "select hubloc_addr, hubloc_id_url from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0",
dbesc($hash) dbesc($hash)
); );
} }

View file

@ -822,6 +822,7 @@ CREATE TABLE IF NOT EXISTS `outq` (
`outq_hash` varchar(255) NOT NULL, `outq_hash` varchar(255) NOT NULL,
`outq_account` int unsigned NOT NULL DEFAULT 0 , `outq_account` int unsigned NOT NULL DEFAULT 0 ,
`outq_channel` int unsigned NOT NULL DEFAULT 0 , `outq_channel` int unsigned NOT NULL DEFAULT 0 ,
`outq_mid` varchar(255) NOT NULL DEFAULT '',
`outq_driver` varchar(128) NOT NULL DEFAULT '', `outq_driver` varchar(128) NOT NULL DEFAULT '',
`outq_posturl` varchar(255) NOT NULL DEFAULT '', `outq_posturl` varchar(255) NOT NULL DEFAULT '',
`outq_async` tinyint NOT NULL DEFAULT 0 , `outq_async` tinyint NOT NULL DEFAULT 0 ,
@ -836,6 +837,7 @@ CREATE TABLE IF NOT EXISTS `outq` (
PRIMARY KEY (`outq_hash`(191)), PRIMARY KEY (`outq_hash`(191)),
KEY `outq_account` (`outq_account`), KEY `outq_account` (`outq_account`),
KEY `outq_channel` (`outq_channel`), KEY `outq_channel` (`outq_channel`),
KEY `outq_mid` (`outq_mid`),
KEY `outq_hub` (`outq_posturl`(191)), KEY `outq_hub` (`outq_posturl`(191)),
KEY `outq_created` (`outq_created`), KEY `outq_created` (`outq_created`),
KEY `outq_updated` (`outq_updated`), KEY `outq_updated` (`outq_updated`),

View file

@ -842,6 +842,7 @@ CREATE TABLE "outq" (
"outq_hash" text NOT NULL, "outq_hash" text NOT NULL,
"outq_account" bigint NOT NULL DEFAULT '0', "outq_account" bigint NOT NULL DEFAULT '0',
"outq_channel" bigint NOT NULL DEFAULT '0', "outq_channel" bigint NOT NULL DEFAULT '0',
"outq_mid" text NOT NULL DEFAULT '',
"outq_driver" varchar(32) NOT NULL DEFAULT '', "outq_driver" varchar(32) NOT NULL DEFAULT '',
"outq_posturl" text NOT NULL DEFAULT '', "outq_posturl" text NOT NULL DEFAULT '',
"outq_async" numeric(1) NOT NULL DEFAULT '0', "outq_async" numeric(1) NOT NULL DEFAULT '0',
@ -857,6 +858,7 @@ CREATE TABLE "outq" (
); );
create index "outq_account" on outq ("outq_account"); create index "outq_account" on outq ("outq_account");
create index "outq_channel" on outq ("outq_channel"); create index "outq_channel" on outq ("outq_channel");
create index "outq_mid" on outq ("outq_mid");
create index "outq_hub" on outq ("outq_posturl"); create index "outq_hub" on outq ("outq_posturl");
create index "outq_created" on outq ("outq_created"); create index "outq_created" on outq ("outq_created");
create index "outq_updated" on outq ("outq_updated"); create index "outq_updated" on outq ("outq_updated");