From 213c8a6eeccc16c34d3a34229a810bd213837c56 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Jan 2023 13:06:50 +0000 Subject: according to spec this should be id instead of href --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1a1031909..940280572 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -595,9 +595,9 @@ class Activity { foreach ($item['term'] as $t) { switch ($t['ttype']) { case TERM_HASHTAG: - // href is required so if we don't have a url in the taxonomy, ignore it and keep going. + // id is required so if we don't have a url in the taxonomy, ignore it and keep going. if ($t['url']) { - $ret[] = ['type' => 'Hashtag', 'href' => $t['url'], 'name' => '#' . $t['term']]; + $ret[] = ['type' => 'Hashtag', 'id' => $t['url'], 'name' => '#' . $t['term']]; } break; -- cgit v1.2.3 From cf1838f76eea5a33f1af78447c7dcf3f52dacc56 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Jan 2023 10:10:06 +0000 Subject: minor cleanup and prevent duplicate recipients in some places --- Zotlabs/Lib/DReport.php | 19 +++---------------- Zotlabs/Lib/Libzot.php | 24 +++++++++--------------- 2 files changed, 12 insertions(+), 31 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php index 2263529b2..e22ed65be 100644 --- a/Zotlabs/Lib/DReport.php +++ b/Zotlabs/Lib/DReport.php @@ -94,19 +94,6 @@ class DReport { if(! $c) return false; - // legacy zot recipients add a space and their name to the xchan. remove it if true. - - $legacy_recipient = strpos($dr['recipient'], ' '); - if($legacy_recipient !== false) { - $legacy_recipient_parts = explode(' ', $dr['recipient'], 2); - $rxchan = $legacy_recipient_parts[0]; - } - else { - $rxchan = $dr['recipient']; - } - - - // is the recipient one of our connections, or do we want to store every report? $pcf = get_pconfig($c[0]['channel_id'],'system','dreport_store_all'); @@ -117,7 +104,7 @@ class DReport { // So if a remote site says they can't find us, that's no big surprise // and just creates a lot of extra report noise - if(($dr['location'] !== z_root()) && ($dr['sender'] === $rxchan) && ($dr['status'] === 'recipient not found')) + if(($dr['location'] !== z_root()) && ($dr['sender'] === $dr['recipient']) && ($dr['status'] === 'recipient not found')) return false; // If you have a private post with a recipient list, every single site is going to report @@ -126,14 +113,14 @@ class DReport { // have a channel on that site. $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_url = '%s'", - dbesc($rxchan), + dbesc($dr['recipient']), dbesc($dr['location']) ); if((! $r) && ($dr['status'] === 'recipient_not_found')) return false; $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", - dbesc($rxchan), + dbesc($dr['recipient']), intval($c[0]['channel_id']) ); if($r) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index c635fdb17..e4be56157 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1051,19 +1051,9 @@ class Libzot { } if (is_array($x) && array_key_exists('delivery_report', $x) && is_array($x['delivery_report'])) { - foreach ($x['delivery_report'] as $xx) { call_hooks('dreport_process', $xx); if (is_array($xx) && array_key_exists('message_id', $xx) && DReport::is_storable($xx)) { - - // legacy recipients add a space and their name to the xchan. split those if true. - $legacy_recipient = strpos($xx['recipient'], ' '); - if ($legacy_recipient !== false) { - $legacy_recipient_parts = explode(' ', $xx['recipient'], 2); - $xx['recipient'] = $legacy_recipient_parts[0]; - $xx['name'] = $legacy_recipient_parts[1]; - } - q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s', '%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), @@ -1435,7 +1425,9 @@ class Libzot { $r = []; - $c = q("select channel_id, channel_hash from channel where channel_removed = 0"); + $c = q("select channel_id, channel_hash from channel where channel_hash != '%s' and channel_removed = 0", + dbesc($msg['sender']) + ); if ($c) { foreach ($c as $cc) { @@ -1463,9 +1455,10 @@ class Libzot { if ($tag['type'] === 'Mention' && (strpos($tag['href'], z_root()) !== false)) { $address = basename($tag['href']); if ($address) { - $z = q("select channel_hash as hash from channel where channel_address = '%s' + $z = q("select channel_hash as hash from channel where channel_address = '%s' and channel_hash != '%s' and channel_removed = 0 limit 1", - dbesc($address) + dbesc($address), + dbesc($msg['sender']) ); if ($z) { $r[] = $z[0]['hash']; @@ -1484,9 +1477,10 @@ class Libzot { $thread_parent = self::find_parent($msg, $act); if ($thread_parent) { - $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ", + $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) and channel_hash != '%s'", + dbesc($thread_parent), dbesc($thread_parent), - dbesc($thread_parent) + dbesc($msg['sender']) ); if ($z) { foreach ($z as $zv) { -- cgit v1.2.3 From 9c3660e2f62a155b700ef04392768b0a2c3bc998 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Feb 2023 10:02:35 +0000 Subject: remove superfluous semicolon --- Zotlabs/Lib/QueueWorker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/QueueWorker.php b/Zotlabs/Lib/QueueWorker.php index fd2ebd7e1..349ccb68f 100644 --- a/Zotlabs/Lib/QueueWorker.php +++ b/Zotlabs/Lib/QueueWorker.php @@ -178,7 +178,7 @@ class QueueWorker { // This is probably the better solution but is not supported by mariadb < 10.6 which is still used a lot. // $work = dbq("SELECT workerq_id FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE SKIP LOCKED;"); - $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE;"); + $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE"); if (!$work) { self::qcommit(); -- cgit v1.2.3 From ea2b653b9bd831e835e19d4f5f1e560cee2f200e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Feb 2023 11:03:29 +0000 Subject: queueworker: do not wait for locked rows, use skip locked if configured via system.db_skip_locked_supported --- Zotlabs/Lib/QueueWorker.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/QueueWorker.php b/Zotlabs/Lib/QueueWorker.php index 349ccb68f..696fb79fc 100644 --- a/Zotlabs/Lib/QueueWorker.php +++ b/Zotlabs/Lib/QueueWorker.php @@ -137,10 +137,26 @@ class QueueWorker { self::$workermaxage = self::$workermaxage > 120 ? self::$workermaxage : 300; } - q("update workerq set workerq_reservationid = null where workerq_reservationid is not null and workerq_processtimeout < %s", + self::qstart(); + + // skip locked is preferred but is not supported by mariadb < 10.6 which is still used a lot - hence make it optional + $sql_quirks = ((get_config('system', 'db_skip_locked_supported')) ? 'SKIP LOCKED' : 'NOWAIT'); + + $r = q("SELECT workerq_id FROM workerq WHERE workerq_reservationid IS NOT NULL AND workerq_processtimeout < %s FOR UPDATE $sql_quirks", db_utcnow() ); + if ($r) { + $ids = ids_to_querystr($r, 'workerq_id'); + $u = dbq("update workerq set workerq_reservationid = null where workerq_id in ($ids)"); + } + + self::qcommit(); + + //q("update workerq set workerq_reservationid = null where workerq_reservationid is not null and workerq_processtimeout < %s", + //db_utcnow() + //); + //usleep(self::$workersleep); $workers = dbq("select count(distinct workerq_reservationid) as total from workerq where workerq_reservationid is not null"); @@ -175,10 +191,10 @@ class QueueWorker { self::qstart(); - // This is probably the better solution but is not supported by mariadb < 10.6 which is still used a lot. - // $work = dbq("SELECT workerq_id FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE SKIP LOCKED;"); + // skip locked is preferred but is not supported by mariadb < 10.6 which is still used a lot - hence make it optional + $sql_quirks = ((get_config('system', 'db_skip_locked_supported')) ? 'SKIP LOCKED' : 'NOWAIT'); - $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE"); + $work = dbq("SELECT workerq_id, workerq_cmd FROM workerq WHERE workerq_reservationid IS NULL ORDER BY workerq_priority DESC, workerq_id ASC LIMIT 1 FOR UPDATE $sql_quirks"); if (!$work) { self::qcommit(); -- cgit v1.2.3 From 09c9b47265b144c905a51434c40002d8aef526e5 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Feb 2023 01:52:48 +0000 Subject: fix more hubloc confusion, implement hq widget author filter and some autocomplete fixes --- Zotlabs/Lib/Libzot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index e4be56157..c2787e03c 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1974,7 +1974,7 @@ class Libzot { $ret = []; - $signer = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1", + $signer = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", dbesc($a['signature']['signer']) ); @@ -2002,7 +2002,7 @@ class Libzot { continue; } - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'", + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", dbesc($AS->actor['id']) ); -- cgit v1.2.3 From 724b8cc6a54c2e778a2d67b2177ecf373f615c64 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Feb 2023 10:41:23 +0000 Subject: port queue improvements from streams --- Zotlabs/Lib/Queue.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index c3f9cda20..23691408a 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -65,16 +65,32 @@ class Queue { ); } - - static function remove($id,$channel_id = 0) { - logger('queue: remove queue item ' . $id,LOGGER_DEBUG); + public static function remove($id, $channel_id = 0) { + logger('queue: remove queue item ' . $id, LOGGER_DEBUG); $sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : ''); - q("DELETE FROM outq WHERE outq_hash = '%s' $sql_extra", + // figure out what endpoint it is going to. + $record = q("select outq_posturl from outq where outq_hash = '%s' $sql_extra", dbesc($id) ); - } + if ($record) { + q("DELETE FROM outq WHERE outq_hash = '%s' $sql_extra", + dbesc($id) + ); + + // If there's anything remaining in the queue for this site, move one of them to the next active + // queue run by setting outq_scheduled back to the present. We may be attempting to deliver it + // as a 'piled_up' delivery, but this ensures the site has an active queue entry as long as queued + // entries still exist for it. This fixes an issue where one immediate delivery left everything + // else for that site undeliverable since all the other entries had been pushed far into the future. + + q("update outq set outq_scheduled = '%s' where outq_posturl = '%s' limit 1", + dbesc(datetime_convert()), + dbesc($record[0]['outq_posturl']) + ); + } + } static function remove_by_posturl($posturl) { logger('queue: remove queue posturl ' . $posturl,LOGGER_DEBUG); @@ -84,8 +100,6 @@ class Queue { ); } - - static function set_delivered($id,$channel = 0) { logger('queue: set delivered ' . $id,LOGGER_DEBUG); $sql_extra = (($channel['channel_id']) ? " and outq_channel = " . intval($channel['channel_id']) . " " : ''); -- cgit v1.2.3 From a1eb39872ba5017be218d48f319addf3d40ff05d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Feb 2023 10:43:31 +0000 Subject: implement hq widget author image and notifications updates --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 2015b260d..823e1df29 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -869,7 +869,7 @@ class Enotify { $x = array( 'notify_link' => $item['llink'], 'name' => $item[$who]['xchan_name'], - 'addr' => $item[$who]['xchan_addr'] ?? $item[$who]['xchan_url'], + 'addr' => $item[$who]['xchan_addr'] ? $item[$who]['xchan_addr'] : $item[$who]['xchan_url'], 'url' => $item[$who]['xchan_url'], 'photo' => $item[$who]['xchan_photo_s'], 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), -- cgit v1.2.3 From 2c459fefceb5208bba91a3acd64644fb65c78274 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Feb 2023 14:13:59 +0000 Subject: remove deprecated functions --- Zotlabs/Lib/Libsync.php | 19 ++------ Zotlabs/Lib/Libzot.php | 114 ------------------------------------------------ 2 files changed, 4 insertions(+), 129 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index 19361c4ae..b0ce7cd12 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -766,11 +766,10 @@ class Libsync { * * @param array $sender * @param array $arr - * @param boolean $absolute (optional) default false * @return array */ - static function sync_locations($sender, $arr, $absolute = false) { + static function sync_locations($sender, $arr) { $ret = []; $what = ''; @@ -787,9 +786,6 @@ class Libsync { if (isset($arr['locations']) && $arr['locations']) { - if ($absolute) - Libzot::check_location_move($sender['hash'], $arr['locations']); - $xisting = q("select * from hubloc where hubloc_hash = '%s'", dbesc($sender['hash']) ); @@ -933,14 +929,7 @@ class Libsync { $what .= 'primary_hub '; $changed = true; } - elseif ($absolute) { - // Absolute sync - make sure the current primary is correctly reflected in the xchan - $pr = hubloc_change_primary($r[0]); - if ($pr) { - $what .= 'xchan_primary '; - $changed = true; - } - } + if (intval($r[0]['hubloc_deleted']) && (!intval($location['deleted']))) { q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), @@ -1011,10 +1000,10 @@ class Libsync { // get rid of any hubs we have for this channel which weren't reported. - if ($absolute && $xisting) { + if ($xisting) { foreach ($xisting as $x) { if (!array_key_exists('updated', $x)) { - logger('Deleting unreferenced hub location ' . $x['hubloc_addr']); + hz_syslog('Deleting unreferenced hub location ' . $x['hubloc_addr']); q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), dbesc($x['hubloc_id_url']) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index c2787e03c..5610a21b2 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2306,120 +2306,6 @@ class Libzot { } - /** - * @brief Processes delivery of profile. - * - * @param string $sender - * @param array $arr - * @param array $deliveries (unused) - * @return void - * @see import_directory_profile() - * - */ - static function process_profile_delivery($sender, $arr, $deliveries) { - - logger('process_profile_delivery', LOGGER_DEBUG); - - $r = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", - dbesc($sender) - ); - if ($r) { - Libzotdir::import_directory_profile($sender, $arr, $r[0]['xchan_addr'], UPDATE_FLAGS_UPDATED, 0); - } - } - - - /** - * @brief - * - * @param string $sender - * @param array $arr - * @param array $deliveries (unused) deliveries is irrelevant - * @return void - */ - static function process_location_delivery($sender, $arr, $deliveries) { - - // deliveries is irrelevant - logger('process_location_delivery', LOGGER_DEBUG); - - $r = q("select * from xchan where xchan_hash = '%s' limit 1", - dbesc($sender) - ); - if ($r) { - $xchan = ['id' => $r[0]['xchan_guid'], 'id_sig' => $r[0]['xchan_guid_sig'], - 'hash' => $r[0]['xchan_hash'], 'public_key' => $r[0]['xchan_pubkey']]; - } - if (array_key_exists('locations', $arr) && $arr['locations']) { - $x = Libsync::sync_locations($xchan, $arr, true); - logger('results: ' . print_r($x, true), LOGGER_DEBUG); - if ($x['changed']) { - //$guid = random_string() . '@' . App::get_hostname(); - Libzotdir::update_modtime($sender, $r[0]['xchan_guid'], $arr['locations'][0]['address'], UPDATE_FLAGS_UPDATED); - } - } - } - - /** - * @brief Checks for a moved channel and sets the channel_moved flag. - * - * Currently the effect of this flag is to turn the channel into 'read-only' mode. - * New content will not be processed (there was still an issue with blocking the - * ability to post comments as of 10-Mar-2016). - * We do not physically remove the channel at this time. The hub admin may choose - * to do so, but is encouraged to allow a grace period of several days in case there - * are any issues migrating content. This packet will generally be received by the - * original site when the basic channel import has been processed. - * - * This will only be executed on the old location - * if a new location is reported and there is only one location record. - * The rest of the hubloc syncronisation will be handled within - * sync_locations - * - * @param string $sender_hash A channel hash - * @param array $locations - * @return void - */ - static function check_location_move($sender_hash, $locations) { - - if (!$locations) - return; - - if (count($locations) != 1) - return; - - $loc = $locations[0]; - - $r = q("select * from channel where channel_hash = '%s' limit 1", - dbesc($sender_hash) - ); - - if (!$r) - return; - - if ($loc['url'] !== z_root()) { - $x = q("update channel set channel_moved = '%s' where channel_hash = '%s' limit 1", - dbesc($loc['url']), - dbesc($sender_hash) - ); - - // federation plugins may wish to notify connections - // of the move on singleton networks - - $arr = [ - 'channel' => $r[0], - 'locations' => $locations - ]; - /** - * @hooks location_move - * Called when a new location has been provided to a UNO channel (indicating a move rather than a clone). - * * \e array \b channel - * * \e array \b locations - */ - call_hooks('location_move', $arr); - } - } - - /** * @brief Returns an array with all known distinct hubs for this channel. * -- cgit v1.2.3 From 09a60774d746de57d6f9e479a1f6cf70c691f031 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Feb 2023 13:33:23 +0000 Subject: we can sign messages which are not from the primary location --- Zotlabs/Lib/Libzot.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 5610a21b2..8b4662bee 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -101,7 +101,6 @@ class Libzot { static function build_packet($channel, $type = 'activity', $recipients = null, $msg = [], $encoding = 'activitystreams', $remote_key = null, $methods = '') { $sig_method = get_config('system', 'signature_algorithm', 'sha256'); - $data = [ 'type' => $type, 'encoding' => $encoding, @@ -115,9 +114,9 @@ class Libzot { } if ($msg) { - $actor = channel_url($channel); - if ($encoding === 'activitystreams' && array_key_exists('actor', $msg) && is_string($msg['actor']) && $actor === $msg['actor']) { - $msg = JSalmon::sign($msg, $actor, $channel['channel_prvkey']); + $actors = get_hubloc_id_urls_by_x($channel['channel_hash']); + if ($encoding === 'activitystreams' && array_key_exists('actor', $msg) && is_string($msg['actor']) && in_array($msg['actor'], $actors)) { + $msg = JSalmon::sign($msg, $actors[0], $channel['channel_prvkey']); } $data['data'] = $msg; } -- cgit v1.2.3 From cbf8c4bdb274f8d9c326961b9d0bf0c2a2ac35a0 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 16 Feb 2023 11:16:44 +0000 Subject: more queue updates from streams and remove a hz_syslog --- Zotlabs/Lib/Libsync.php | 4 ++-- Zotlabs/Lib/Queue.php | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index b0ce7cd12..d52b501e4 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -998,12 +998,12 @@ class Libsync { } } - // get rid of any hubs we have for this channel which weren't reported. + // get rid of any hublocs we have for this channel which weren't reported. if ($xisting) { foreach ($xisting as $x) { if (!array_key_exists('updated', $x)) { - hz_syslog('Deleting unreferenced hub location ' . $x['hubloc_addr']); + logger('Deleting unreferenced hub location ' . $x['hubloc_addr']); q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), dbesc($x['hubloc_id_url']) diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 23691408a..c48b59c86 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -166,17 +166,18 @@ class Queue { $y = q("select site_update, site_dead from site where site_url = '%s' ", dbesc($base) ); - if($y) { - if(intval($y[0]['site_dead'])) { - self::remove_by_posturl($outq['outq_posturl']); - logger('dead site ignored ' . $base); - return; - } - if($y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { - self::update($outq['outq_hash'], 10); - logger('immediate delivery deferred for site ' . $base); - return; - } + + // Don't bother delivering if the site is dead. + // And if we haven't heard from the site in over a month - let them through but 3 strikes you're out. + if ($y && (intval($y[0]['site_dead']) || ($y[0]['site_update'] < datetime_convert('UTC', 'UTC', 'now - 1 month') && $outq['outq_priority'] > 20 ))) { + q("update dreport set dreport_result = '%s' where dreport_queue = '%s'", + dbesc('site dead'), + dbesc($outq['outq_hash']) + ); + + self::remove_by_posturl($outq['outq_posturl']); + logger('dead site ignored ' . $base); + return; } else { -- cgit v1.2.3 From 7839b931f1ec66ea576593f58f7141e8097bb201 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Feb 2023 13:12:22 +0100 Subject: make sure we provide a created timestamp for likes and remove the workaround which returned the wrong date format --- Zotlabs/Lib/Activity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 940280572..68ac320ba 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -822,7 +822,8 @@ class Activity { ]; } - $ret['published'] = ((isset($i['created'])) ? datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME) : datetime_convert()); + $ret['published'] = datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME); + if (isset($i['created'], $i['edited']) && $i['created'] !== $i['edited']) { $ret['updated'] = datetime_convert('UTC', 'UTC', $i['edited'], ATOM_TIME); if ($ret['type'] === 'Create') { -- cgit v1.2.3 From 62a363debccd7027a02b520614a53e523df15d1b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 16 Feb 2023 14:17:05 +0000 Subject: queue fixes --- Zotlabs/Lib/Queue.php | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index c48b59c86..348a2a079 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -85,10 +85,29 @@ class Queue { // entries still exist for it. This fixes an issue where one immediate delivery left everything // else for that site undeliverable since all the other entries had been pushed far into the future. - q("update outq set outq_scheduled = '%s' where outq_posturl = '%s' limit 1", - dbesc(datetime_convert()), + $x = null; + $sql_quirks = ((get_config('system', 'db_skip_locked_supported')) ? 'SKIP LOCKED' : 'NOWAIT'); + + q("START TRANSACTION"); + + $r = q("SELECT outq_hash FROM outq WHERE outq_posturl = '%s' LIMIT 1 FOR UPDATE $sql_quirks", dbesc($record[0]['outq_posturl']) ); + + if ($r) { + $x = q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_hash = '%s'", + dbesc(datetime_convert()), + dbesc($r[0]['outq_hash']) + ); + } + + if ($x) { + q("COMMIT"); + } + else { + q("ROLLBACK"); + } + } } @@ -167,17 +186,18 @@ class Queue { dbesc($base) ); - // Don't bother delivering if the site is dead. - // And if we haven't heard from the site in over a month - let them through but 3 strikes you're out. - if ($y && (intval($y[0]['site_dead']) || ($y[0]['site_update'] < datetime_convert('UTC', 'UTC', 'now - 1 month') && $outq['outq_priority'] > 20 ))) { - q("update dreport set dreport_result = '%s' where dreport_queue = '%s'", - dbesc('site dead'), - dbesc($outq['outq_hash']) - ); - - self::remove_by_posturl($outq['outq_posturl']); - logger('dead site ignored ' . $base); - return; + if ($y) { + // Don't bother delivering if the site is dead. + // And if we haven't heard from the site in over a month - let them through but 3 strikes you're out. + if (intval($y[0]['site_dead']) || ($y[0]['site_update'] < datetime_convert('UTC', 'UTC', 'now - 1 month') && $outq['outq_priority'] > 20)) { + q("update dreport set dreport_result = '%s' where dreport_queue = '%s'", + dbesc('site dead'), + dbesc($outq['outq_hash']) + ); + self::remove_by_posturl($outq['outq_posturl']); + logger('dead site ignored ' . $base); + return; + } } else { -- cgit v1.2.3 From 352713726414d2e1dac1c06040bedbb84bb77db6 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Feb 2023 10:47:11 +0000 Subject: Activity: set xchan_pubforum if we deal with a group actor --- Zotlabs/Lib/Activity.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 68ac320ba..a17648147 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1691,6 +1691,8 @@ class Activity { } } + $group_actor = ($person_obj['type'] === 'Group'); + $r = q("select * from xchan join hubloc on xchan_hash = hubloc_hash where xchan_hash = '%s'", dbesc($url) ); @@ -1709,11 +1711,12 @@ class Activity { ); // update existing xchan record - q("update xchan set xchan_name = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'", + q("update xchan set xchan_name = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s', xchan_pubforum = %d where xchan_hash = '%s'", dbesc(escape_tags($name)), dbesc(escape_tags($pubkey)), dbesc(escape_tags($webfinger_addr)), dbescdate(datetime_convert()), + intval($group_actor), dbesc($url) ); @@ -1740,7 +1743,8 @@ class Activity { 'xchan_url' => $profile, 'xchan_name' => escape_tags($name), 'xchan_name_date' => datetime_convert(), - 'xchan_network' => 'activitypub' + 'xchan_network' => 'activitypub', + 'xchan_pubforum' => intval($group_actor) ] ); @@ -2219,7 +2223,6 @@ class Activity { ) { return false; } - // Within our family of projects, Follow/Unfollow of a thread is an internal activity which should not be transmitted, // hence if we receive it - ignore or reject it. // Unfollow is not defined by ActivityStreams, which prefers Undo->Follow. -- cgit v1.2.3 From ca7bd4996403fac432f1594d8552c727c44b360a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Feb 2023 11:20:32 +0000 Subject: Activity: do not force new thread if the announce is from a group actor --- Zotlabs/Lib/Activity.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index a17648147..93432c5ee 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2518,7 +2518,11 @@ class Activity { if ($act->type === 'Announce') { $s['author_xchan'] = self::get_attributed_to_actor_url($act); $s['mid'] = $act->obj['id']; - $s['parent_mid'] = $act->obj['id']; + + // Do not force new thread if the announce is from a group actor + if ($act->actor['type'] !== 'Group') { + $s['parent_mid'] = $act->obj['id']; + } } // we will need a hook here to extract magnet links e.g. peertube -- cgit v1.2.3 From efcda1d37d609677b4fdc6a12c63feea250a3f5e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Feb 2023 09:51:37 +0000 Subject: port some functions from streams --- Zotlabs/Lib/ActivityStreams.php | 59 ++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index a07fdacb7..9049ffb5d 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -145,36 +145,59 @@ class ActivityStreams { $this->saved_recips = $arr; } + /** + * @brief get single property from Activity object + * + * @param string $property + * @param mixed $default return value if property or object not set + * or object is a string id which could not be fetched. + * @return mixed + */ + public function objprop(string $property, mixed $default = false): mixed { + $x = $this->get_property_obj($property,$this->obj); + return (isset($x)) ? $x : $default; + } + /** * @brief Collects all recipients. * - * @param string $base + * @param mixed $base * @param string $namespace (optional) default empty * @return array */ - function collect_recips($base = '', $namespace = '') { - $x = []; + public function collect_recips(mixed $base = '', string $namespace = ''): array { + $result = []; + $tmp = []; $fields = ['to', 'cc', 'bto', 'bcc', 'audience']; - foreach ($fields as $f) { - $y = $this->get_compound_property($f, $base, $namespace); - if ($y) { - if (!is_array($this->raw_recips)) { - $this->raw_recips = []; - } - - if (!is_array($y)) { - $y = [$y]; - } - $this->raw_recips[$f] = $y; - $x = array_merge($x, $y); + foreach ($fields as $field) { + // don't expand these yet + $values = $this->get_property_obj($field, $base, $namespace); + if ($values) { + $values = force_array($values); + $tmp[$field] = $values; + $result = array_values(array_unique(array_merge($result, $values))); + } + // Merge the object recipients if they exist. + $values = $this->objprop($field); + if ($values) { + $values = force_array($values); + $tmp[$field] = (($tmp[$field]) ? array_merge($tmp[$field], $values) : $values); + $result = array_values(array_unique(array_merge($result, $values))); + } + // remove duplicates + if (is_array($tmp[$field])) { + $tmp[$field] = array_values(array_unique($tmp[$field])); } } -// not yet ready for prime time -// $x = $this->expand($x,$base,$namespace); - return $x; + $this->raw_recips = $tmp; + + // not yet ready for prime time + // $result = $this->expand($result,$base,$namespace); + return $result; } + function expand($arr, $base = '', $namespace = '') { $ret = []; -- cgit v1.2.3 From 828087ee8cd3a57050fa08a36c19cc904889681f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Feb 2023 14:54:04 +0000 Subject: fix syntax for get_compund_property() --- Zotlabs/Lib/ActivityStreams.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 9049ffb5d..1a6fe9c1b 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -113,7 +113,7 @@ class ActivityStreams { // fetch recursive or embedded activities if ($this->obj && is_array($this->obj) && array_key_exists('object', $this->obj)) { - $this->obj['object'] = $this->get_compound_property($this->obj['object']); + $this->obj['object'] = $this->get_compound_property('object', $this->obj); } if ($this->obj && is_array($this->obj) && isset($this->obj['actor'])) @@ -364,6 +364,7 @@ class ActivityStreams { */ function get_compound_property($property, $base = '', $namespace = '', $first = false) { $x = $this->get_property_obj($property, $base, $namespace); + if ($this->is_url($x)) { $y = $this->fetch_property($x); if (is_array($y)) { -- cgit v1.2.3 From f032bcc5f2abccd66308e7eb9491d01d7382375b Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 27 Feb 2023 08:42:13 +0000 Subject: Default owner_xchan to $observer (sender) in Activity::store() - this is because in case where an announce holds a relayed activity we drop the announce and process the relayed activity only. In that case actor.id as set in Activity::decode_note() will not be the correct owner. In other cases actor.id and sender should be identical. --- Zotlabs/Lib/Activity.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 93432c5ee..dc868c93e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2852,6 +2852,7 @@ class Activity { } $allowed = false; + $item['owner_xchan'] = $observer_hash; // TODO: not implemented // $permit_mentions = intval(PConfig::Get($channel['channel_id'], 'system','permit_all_mentions') && i_am_mentioned($channel,$item)); -- cgit v1.2.3 From ca0bd3ed3251e2558dc4a53abed417dd9da6244d Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 28 Feb 2023 09:29:39 +0000 Subject: fix some php warnings --- Zotlabs/Lib/ActivityStreams.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 1a6fe9c1b..cfed53b3c 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -182,11 +182,11 @@ class ActivityStreams { $values = $this->objprop($field); if ($values) { $values = force_array($values); - $tmp[$field] = (($tmp[$field]) ? array_merge($tmp[$field], $values) : $values); + $tmp[$field] = ((isset($tmp[$field])) ? array_merge($tmp[$field], $values) : $values); $result = array_values(array_unique(array_merge($result, $values))); } // remove duplicates - if (is_array($tmp[$field])) { + if (isset($tmp[$field])) { $tmp[$field] = array_values(array_unique($tmp[$field])); } } -- cgit v1.2.3 From b457c66bf9320d35427ce82aeeefed387ebbba38 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Mar 2023 10:13:54 +0000 Subject: do not include deleted hublocs when looking for author --- Zotlabs/Lib/Libzot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 8b4662bee..f22b475be 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1243,7 +1243,7 @@ class Libzot { return; } - $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", + $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_deleted = 0 order by hubloc_id desc", dbesc($AS->actor['id']) ); @@ -1251,7 +1251,7 @@ class Libzot { // Author is unknown to this site. Perform channel discovery and try again. $z = discover_by_webbie($AS->actor['id']); if ($z) { - $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", + $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_deleted = 0 order by hubloc_id desc", dbesc($AS->actor['id']) ); } -- cgit v1.2.3 From 3653a86ad3fe9b5ca40db1e3cabe7b7636bf2b86 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Mar 2023 11:00:03 +0000 Subject: message filter entries are stored encoded - make sure to decode the word before we use it --- Zotlabs/Lib/MessageFilter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php index 7d6dcbe8e..e7382c0d5 100644 --- a/Zotlabs/Lib/MessageFilter.php +++ b/Zotlabs/Lib/MessageFilter.php @@ -25,7 +25,7 @@ class MessageFilter { if ($exclude) { foreach ($exclude as $word) { - $word = trim($word); + $word = html_entity_decode(trim($word)); if (! $word) { continue; } @@ -73,7 +73,7 @@ class MessageFilter { if ($include) { foreach ($include as $word) { - $word = trim($word); + $word = html_entity_decode(trim($word)); if (! $word) { continue; } -- cgit v1.2.3 From da034045cc1bba74287b7c3e83f4a94ff5359150 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Mar 2023 21:15:19 +0000 Subject: some work on bringing bang tags back for forums --- Zotlabs/Lib/Activity.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index dc868c93e..60284c56d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -570,7 +570,12 @@ class Activity { break; case 'Mention': - $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; + $mention_type = substr($t['name'], 0, 1); + if ($mention_type === '!') { + $ret[] = ['ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; + } else { + $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; + } break; case 'Bookmark': @@ -605,6 +610,10 @@ class Activity { $ret[] = ['type' => 'Mention', 'href' => $t['url'], 'name' => '@' . $t['term']]; break; + case TERM_FORUM: + $ret[] = ['type' => 'Mention', 'href' => $t['url'], 'name' => '!' . $t['term']]; + break; + case TERM_BOOKMARK: $ret[] = ['type' => 'Bookmark', 'href' => $t['url'], 'name' => $t['term']]; break; @@ -936,7 +945,7 @@ class Activity { if (!$t['url']) { continue; } - if ($t['ttype'] == TERM_MENTION) { + if (in_array($t['ttype'], [TERM_MENTION, TERM_FORUM])) { $url = self::lookup_term_url($t['url']); $list[] = (($url) ? $url : $t['url']); } -- cgit v1.2.3 From ec3ba87f3a6cb9cda5f094bb1e62ed6b746f087f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Mar 2023 08:49:18 +0000 Subject: Revert "some work on bringing bang tags back for forums" This reverts commit da034045cc1bba74287b7c3e83f4a94ff5359150. --- Zotlabs/Lib/Activity.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 60284c56d..dc868c93e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -570,12 +570,7 @@ class Activity { break; case 'Mention': - $mention_type = substr($t['name'], 0, 1); - if ($mention_type === '!') { - $ret[] = ['ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; - } else { - $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; - } + $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; break; case 'Bookmark': @@ -610,10 +605,6 @@ class Activity { $ret[] = ['type' => 'Mention', 'href' => $t['url'], 'name' => '@' . $t['term']]; break; - case TERM_FORUM: - $ret[] = ['type' => 'Mention', 'href' => $t['url'], 'name' => '!' . $t['term']]; - break; - case TERM_BOOKMARK: $ret[] = ['type' => 'Bookmark', 'href' => $t['url'], 'name' => $t['term']]; break; @@ -945,7 +936,7 @@ class Activity { if (!$t['url']) { continue; } - if (in_array($t['ttype'], [TERM_MENTION, TERM_FORUM])) { + if ($t['ttype'] == TERM_MENTION) { $url = self::lookup_term_url($t['url']); $list[] = (($url) ? $url : $t['url']); } -- cgit v1.2.3 From 972d6917ac9e23d4032f375e2aec8f1839581b06 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Mar 2023 14:59:48 +0000 Subject: add fixme --- Zotlabs/Lib/Activity.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index dc868c93e..817d2851d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1773,6 +1773,10 @@ class Activity { dbesc($url) ); if (!$zx) { + // FIXME: we might need to fetch and store this url immediately + // otherwise at least the first post of a yet unknown author might + // be stored with the activitypub url instead of the portable id. + // Another solution could be to fix the items after Gprobe has done its work. Master::Summon(['Gprobe', bin2hex($url)]); } } -- cgit v1.2.3 From 198751783623cdcd65701314a81e9c3b75b5dd2e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Mar 2023 18:31:43 +0000 Subject: only set owner to observer if the item is not fetched otherwise the comment author could end up as owner --- Zotlabs/Lib/Activity.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 817d2851d..171c0150e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2855,8 +2855,11 @@ class Activity { $is_child_node = true; } + if (empty($item['item_fetched'])) { + $item['owner_xchan'] = $observer_hash; + } + $allowed = false; - $item['owner_xchan'] = $observer_hash; // TODO: not implemented // $permit_mentions = intval(PConfig::Get($channel['channel_id'], 'system','permit_all_mentions') && i_am_mentioned($channel,$item)); @@ -2932,7 +2935,7 @@ class Activity { // The $item['item_fetched'] flag is set in fetch_and_store_parents(). // In this case we should check against author permissions because sender is not owner. - if (perm_is_allowed($channel['channel_id'], ((isset($item['item_fetched']) && $item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) { + if (perm_is_allowed($channel['channel_id'], ((!empty($item['item_fetched'])) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) { $allowed = true; } // TODO: not implemented @@ -3241,7 +3244,7 @@ class Activity { $item = $hookinfo['item']; if ($item) { - $item['item_fetched'] = 1; + $item['item_fetched'] = true; if (intval($channel['channel_system']) && intval($item['item_private'])) { $p = []; @@ -3355,7 +3358,7 @@ class Activity { return false; } - */ + static public function fetch_and_store_replies($channel, $arr) { logger('fetching replies'); @@ -3412,6 +3415,7 @@ class Activity { } } +*/ /* this is deprecated and not used anymore static function announce_note($channel, $observer_hash, $act) { -- cgit v1.2.3 From 641b1c2e1b5be0d5b7b94ea6566238baa830ebe4 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 11 Mar 2023 19:38:37 +0000 Subject: fix php error --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index f22b475be..93d8a39c0 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1366,7 +1366,7 @@ class Libzot { return false; } $x = self::find_parent($env, $act); - if ($x === $act->id || $x === $act->obj['id']) { + if ($x === $act->id || (is_array($act->obj) && array_key_exists('id', $act->obj) && $x === $act->obj['id'])) { return true; } } -- cgit v1.2.3 From 9daecca0ad4b748f87561c0f8d892ff9b74c5a0e Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Mar 2023 09:34:35 +0000 Subject: make an format exception for repeated forum posts --- Zotlabs/Lib/Enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 823e1df29..585761cc4 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -828,7 +828,7 @@ class Enotify { : (($item['obj_type'] === 'Answer') ? sprintf( t('voted on %s\'s poll'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]') : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')) ); - if($item['verb'] === ACTIVITY_SHARE) { + if($item['verb'] === ACTIVITY_SHARE && empty($item['owner']['xchan_pubforum'])) { $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); } @@ -860,7 +860,7 @@ class Enotify { // convert this logic into a json array just like the system notifications - $who = (($item['verb'] === ACTIVITY_SHARE) ? 'owner' : 'author'); + $who = (($item['verb'] === ACTIVITY_SHARE && empty($item['owner']['xchan_pubforum'])) ? 'owner' : 'author'); $body = html2plain(bbcode($item['body'], ['drop_media' => true, 'tryoembed' => false]), 75, true); if ($body) { $body = htmlentities($body, ENT_QUOTES, 'UTF-8', false); -- cgit v1.2.3 From 7e4721e4c75a4dd480c6f7cc1a8d70507c6d1b97 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Mar 2023 10:35:01 +0000 Subject: work around friendica img attachment has different href than body which results in duplicate images --- Zotlabs/Lib/Activity.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 171c0150e..226f50636 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -700,6 +700,13 @@ class Activity { if (array_key_exists('name', $att) && $att['name']) { $entry['name'] = html2plain(purify_html($att['name']), 256); } + // Friendica attachments don't match the URL in the body. + // This makes it more difficult to detect image duplication in bb_attach() + // which adds images to plaintext microblog software. For these we need to examine both the + // url and image properties. + if (isset($att['image']) && is_string($att['image']) && isset($att['url']) && $att['image'] !== $att['url']) { + $entry['image'] = $att['image']; + } if ($entry) { $ret[] = $entry; } @@ -2601,13 +2608,13 @@ class Activity { if ($mps) { usort($mps,[ '\Zotlabs\Lib\Activity', 'vid_sort' ]); foreach ($mps as $m) { - if (intval($m['height']) < 500 && Activity::media_not_in_body($m['href'],$s['body'])) { + if (intval($m['height']) < 500 && self::media_not_in_body($m['href'],$s['body'])) { $s['body'] = $tag . $m['href'] . '[/video]' . "\r\n" . $s['body']; break; } } } - elseif (is_string($act->obj['url']) && Activity::media_not_in_body($act->obj['url'],$s['body'])) { + elseif (is_string($act->obj['url']) && self::media_not_in_body($act->obj['url'],$s['body'])) { $s['body'] = $tag . $act->obj['url'] . '[/video]' . "\r\n" . $s['body']; } @@ -3691,7 +3698,21 @@ class Activity { if ($a['type'] === 'image/svg+xml' && strpos($item['body'], '[/svg]')) { continue; } - if (self::media_not_in_body($a['href'], $item['body'])) { + // Friendica attachment weirdness + // Check both the attachment image and href since they can be different and the one in the href is a different link with different resolution. + // Otheriwse you'll get duplicated images + if (isset($a['image'])) { + if (self::media_not_in_body($a['image'], $item['body']) && self::media_not_in_body($a['href'], $item['body'])) { + if (isset($a['name']) && $a['name']) { + $alt = htmlspecialchars($a['name'], ENT_QUOTES); + $item['body'] = '[img=' . $a['href'] . ']' . $alt . '[/img]' . "\r\n" . $item['body']; + } else { + $item['body'] = '[img]' . $a['href'] . '[/img]' . "\r\n" . $item['body']; + } + } + continue; + } + elseif (self::media_not_in_body($a['href'], $item['body'])) { if (isset($a['name']) && $a['name']) { $alt = htmlspecialchars($a['name'], ENT_QUOTES); $item['body'] = '[img=' . $a['href'] . ']' . $alt . '[/img]' . "\r\n" . $item['body']; -- cgit v1.2.3