diff options
Diffstat (limited to 'Zotlabs/Daemon/Notifier.php')
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 4e7ca3911..9fdb1defb 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -2,8 +2,9 @@ namespace Zotlabs\Daemon; -use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Activity; +use Zotlabs\Lib\Config; +use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Queue; require_once('include/html2plain.php'); @@ -240,11 +241,6 @@ class Notifier { $target_item = $r[0]; - if (in_array($target_item['author']['xchan_network'], ['rss', 'anon', 'token'])) { - logger('notifier: target item author is not a fetchable actor', LOGGER_DEBUG); - return; - } - if (intval($target_item['item_deleted'])) { logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG); } @@ -267,22 +263,9 @@ class Notifier { } - // Check for non published items, but allow an exclusion for transmitting hidden file activities - - if (intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) || - intval($target_item['item_blocked']) || intval($target_item['item_hidden'])) { - logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG); - return; - } - - // follow/unfollow is for internal use only - if (in_array($target_item['verb'], ['Follow', 'Ignore', ACTIVITY_FOLLOW, ACTIVITY_UNFOLLOW])) { - logger('not fowarding follow/unfollow note activity'); - return; - } - - if (strpos($target_item['postopts'], 'nodeliver') !== false) { - logger('notifier: target item is undeliverable', LOGGER_DEBUG); + if (!item_forwardable($target_item)) { + //hz_syslog(print_r($target_item,true)); + logger('notifier: target item not forwardable', LOGGER_DEBUG); return; } @@ -298,7 +281,7 @@ class Notifier { return; } - if ($target_item['verb'] === ACTIVITY_SHARE) { + if (in_array($target_item['verb'], [ACTIVITY_SHARE])) { // Provide correct representation across the wire. Internally this is treated as a comment. $target_item['parent_mid'] = $target_item['thr_parent'] = $target_item['mid']; } @@ -340,7 +323,13 @@ class Notifier { self::$encoded_item = json_decode($m, true); } else { - self::$encoded_item = Activity::build_packet(Activity::encode_activity($target_item), self::$channel, false); + $activity = Activity::encode_activity($target_item); + + if (!$activity) { + return; + } + + self::$encoded_item = Activity::build_packet($activity, self::$channel, false); } logger('target_item: ' . print_r($target_item, true), LOGGER_DEBUG); @@ -357,6 +346,10 @@ class Notifier { $relay_to_owner = (!$top_level_post && intval($target_item['item_origin']) && comment_local_origin($target_item)); + if (self::$channel['channel_hash'] === $target_item['owner_xchan']) { + $relay_to_owner = false; + } + // $cmd === 'relay' indicates the owner is sending it to the original recipients // don't allow the item in the relay command to relay to owner under any circumstances, it will loop @@ -373,7 +366,6 @@ class Notifier { if (($relay_to_owner || $uplink) && ($cmd !== 'relay')) { logger('notifier: followup relay', LOGGER_DEBUG); - // If the Parent item is an Announce the real owner is the parent author $sendto = (($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']); self::$recipients = [$sendto]; self::$private = true; @@ -388,7 +380,7 @@ class Notifier { logger('normal (downstream) distribution', LOGGER_DEBUG); } - if ($parent_item && $parent_item['item_private'] !== $target_item['item_private']) { + if (($parent_item && $parent_item['item_private'] !== $target_item['item_private']) || (intval($target_item['item_restrict']) & 1)) { logger('conversation privacy mismatch - downstream delivery prevented'); return; } @@ -588,8 +580,6 @@ class Notifier { foreach ($dhubs as $hub) { - logger('notifier_hub: ' . $hub['hubloc_url'], LOGGER_DEBUG); - if ($hub['hubloc_network'] !== 'zot6') { $narr = [ 'channel' => self::$channel, @@ -668,7 +658,7 @@ class Notifier { ); // only create delivery reports for normal undeleted items - if (is_array($target_item) && (!$target_item['item_deleted']) && (!get_config('system', 'disable_dreport'))) { + if (is_array($target_item) && (!$target_item['item_deleted']) && (!Config::Get('system', 'disable_dreport'))) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan, dreport_queue ) values ( '%s', '%s','%s','%s','%s','%s','%s','%s' ) ", dbesc($target_item['mid']), @@ -698,7 +688,7 @@ class Notifier { do_delivery(self::$deliveries); } - if ($dead_hosts && is_array($target_item) && (!$target_item['item_deleted']) && (!get_config('system', 'disable_dreport'))) { + if ($dead_hosts && is_array($target_item) && (!$target_item['item_deleted']) && (!Config::Get('system', 'disable_dreport'))) { foreach ($dead_hosts as $deceased_host) { $r = q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan, dreport_queue ) values ( '%s', '%s','%s','%s','%s','%s','%s','%s' ) ", |