diff options
Diffstat (limited to 'include/items.php')
-rwxr-xr-x | include/items.php | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/include/items.php b/include/items.php index 02d31fcb5..a14e3db3a 100755 --- a/include/items.php +++ b/include/items.php @@ -7,6 +7,7 @@ use Zotlabs\Lib\Enotify; use Zotlabs\Lib\MarkdownSoap; use Zotlabs\Lib\MessageFilter; +use Zotlabs\Lib\ThreadListener; use Zotlabs\Lib\IConfig; use Zotlabs\Access\PermissionLimits; use Zotlabs\Access\AccessList; @@ -25,7 +26,7 @@ require_once('include/permissions.php'); * * @param array $item * @param[out] boolean $private_envelope - * @param boolean $include_groups + * @param boolean $include_groups * @return array containing the recipients */ function collect_recipients($item, &$private_envelope,$include_groups = true) { @@ -95,9 +96,24 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { //$sys = get_sys_channel(); if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') { - $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ", + + $hookinfo = [ + 'recipients' => [], + 'item' => $item, + 'private_envelope' => $private_envelope, + 'include_groups' => $include_groups + ]; + + call_hooks('collect_public_recipients',$hookinfo); + + if ($hookinfo['recipients']) { + $r = $hookinfo['recipients']; + } else { + $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ", intval($item['uid']) - ); + ); + } + if($r) { // filter out restrictive public_policy settings from remote networks @@ -126,6 +142,22 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { // $recipients[] = $sys['xchan_hash']; } + + // Forward to thread listeners, *unless* there is even a remote hint that the item + // might have some privacy attached. This could be (for instance) an ActivityPub DM + // in the middle of a public thread. Unless we can guarantee beyond all doubt that + // this is public, don't allow it to go to thread listeners. + + if(! intval($item['item_private'])) { + $r = ThreadListener::fetch_by_target($item['parent_mid']); + if($r) { + foreach($r as $rv) { + $recipients[] = $rv['portable_id']; + } + } + } + + // Add the authors of any posts in this thread, if they are known to us. // This is specifically designed to forward wall-to-wall posts to the original author, // in case they aren't a connection but have permission to write on our wall. @@ -395,7 +427,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) { if(! $arr['mid']) { - $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id()); + $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id()); } $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? $arr['parent_mid'] : $arr['mid']); @@ -2033,6 +2065,11 @@ function item_store($arr, $allow_exec = false, $deliver = true) { item_update_parent_commented($arr); + + if(strpos($arr['body'],'[embed]') !== false) { + Master::Summon([ 'Cache_embeds', $current_post ]); + } + // If _creating_ a deleted item, don't propagate it further or send out notifications. // We need to store the item details just in case the delete came in before the original post, // so that we have an item in the DB that's marked deleted and won't store a fresh post @@ -2369,6 +2406,13 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { */ call_hooks('item_stored_update',$arr); + if(strpos($arr['body'],'[embed]') !== false) { + Master::Summon([ 'Cache_embeds', $orig_post_id ]); + } + + + + if($deliver) { send_status_notifications($orig_post_id,$arr); tag_deliver($uid,$orig_post_id); @@ -2385,15 +2429,15 @@ function item_update_parent_commented($item) { $update_parent = true; - // update the commented timestamp on the parent + // update the commented timestamp on the parent // - unless this is a moderated comment or a potential clone of an older item - // which we don't wish to bring to the surface. As the queue only holds deliveries - // for 3 days, it's suspected of being an older cloned item if the creation time + // which we don't wish to bring to the surface. As the queue only holds deliveries + // for 3 days, it's suspected of being an older cloned item if the creation time //is older than that. if(intval($item['item_blocked']) === ITEM_MODERATED) $update_parent = false; - + if($item['created'] < datetime_convert('','','now - 4 days')) $update_parent = false; @@ -2989,7 +3033,9 @@ function tgroup_check($uid, $item) { * @param array $channel * @param array $item * @param int $item_id - * @param boolean $parent + * @param array $parent + * @param boolean $edit (optional) default false + * @return void */ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) { @@ -3024,7 +3070,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) } // This will change the author to the post owner. Useful for RSS feeds which are to be syndicated - // to federated platforms which can't verify the identity of the author. + // to federated platforms which can't verify the identity of the author. // This MAY cause you to run afoul of copyright law. $rewrite_author = intval(get_abconfig($channel['channel_id'],$item['owner_xchan'],'system','rself')); @@ -3537,7 +3583,7 @@ function item_expire($uid,$days,$comment_days = 7) { if(! $comment_days) $comment_days = 7; - + // $expire_network_only = save your own wall posts // and just expire conversations started by others // do not enable this until we can pass bulk delete messages through zot @@ -3838,6 +3884,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { intval(TERM_OBJ_POST) ); + ThreadListener::delete_by_target($item['mid']); + /** @FIXME remove notifications for this item */ return true; @@ -4532,7 +4580,7 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, $first_access_tag = true; foreach($linkified as $x) { - $access_tag = $x['access_tag']; + $access_tag = $x['success']['access_tag']; if(($access_tag) && (! $parent_item)) { logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DATA); if ($first_access_tag && (! get_pconfig($profile_uid,'system','no_private_mention_acl_override'))) { @@ -4877,7 +4925,7 @@ function copy_of_pubitem($channel,$mid) { dbesc($mid), intval($syschan['channel_id']) ); - + if($r) { $items = fetch_post_tags($r,true); foreach($items as $rv) { @@ -4903,5 +4951,5 @@ function copy_of_pubitem($channel,$mid) { } } - return $result; + return $result; } |