diff --git a/Code/Daemon/Notifier.php b/Code/Daemon/Notifier.php index f55392b44..e943766c1 100644 --- a/Code/Daemon/Notifier.php +++ b/Code/Daemon/Notifier.php @@ -365,7 +365,7 @@ class Notifier implements DaemonInterface // avoid looping of discover items 12/4/2014 - if ($sys && $parent_item['uid'] == $sys['channel_id']) { + if ($sys && (int)$parent_item['uid'] === (int)$sys['channel_id']) { return; } diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 58ce6c6c0..e1b24f0c7 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -4249,16 +4249,15 @@ class Activity dbesc($item['mid']), intval($item['uid']) ); + ObjCache::Set($item['mid'], $act->raw); if ($r) { if ($item['edited'] > $r[0]['edited']) { $item['id'] = $r[0]['id']; - ObjCache::Set($item['mid'], $act->raw); $x = item_store_update($item, deliver: false); } else { return; } } else { - ObjCache::Set($item['mid'], $act->raw); $x = item_store($item, deliver: false, addAndSync: false); } diff --git a/Code/Module/Moderate.php b/Code/Module/Moderate.php index 4b320e2c7..c373c1022 100644 --- a/Code/Module/Moderate.php +++ b/Code/Module/Moderate.php @@ -93,7 +93,6 @@ class Moderate extends Controller $item['item_blocked'] = 0; item_update_parent_commented($item); -// \Code\Lib\Activity::send_accept_activity(App::get_channel(),$item['author'], $item, $parent_item); notice(t('Comment approved') . EOL); } elseif ($action === 'drop') { drop_item($post_id); diff --git a/include/items.php b/include/items.php index 5886ee134..e4381c63b 100644 --- a/include/items.php +++ b/include/items.php @@ -2846,10 +2846,9 @@ function tgroup_check($uid, $item) { // If a comment, check if we have already accepted the top level post as an uplink // Applies to collections only at this time - // @FIXME We need a comment clause for groups if ($item['mid'] !== $item['parent_mid']) { - $r = q("select id from item where mid = '%s' and uid = %d and item_uplink = 1 limit 1", + $r = q("select id from item where mid = '%s' and uid = %d and (item_uplink = 1 or item_wall = 1) limit 1", dbesc($item['parent_mid']), intval($uid) ); @@ -3103,14 +3102,12 @@ function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $gr } } - $arr['tgt_type'] = $item['tgt_type']; - - if (is_array($item['target'])) { - $arr['target'] = $item['target']['id']; - } - else { - $arr['target'] = $item['target']; - } + $arr['tgt_type'] = 'Collection'; + $arr['target'] = [ + 'id' => str_replace('/item/', '/conversation/', $arr['parent_mid']), + 'type' => 'Collection', + 'attributedTo' => z_root() . '/channel/' . $channel['channel_address'], + ]; // Add a mention for the author. $arr['term'] = ($item['term']) ?: []; @@ -3129,8 +3126,6 @@ function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $gr $arr['verb'] = 'Create'; - $arr['item_restrict'] = 1; - $arr['allow_cid'] = $channel['channel_allow_cid']; $arr['allow_gid'] = $channel['channel_allow_gid']; $arr['deny_cid'] = $channel['channel_deny_cid']; @@ -3149,6 +3144,22 @@ function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $gr } $arr['replyto'] = z_root() . '/channel/' . $channel['channel_address']; + if (!array_key_exists('obj', $arr)) { + $copy = $arr; + $copy['author'] = $channel; + $arr['obj'] = Activity::encode_item($copy, ((get_config('system', 'activitypub', ACTIVITYPUB_ENABLED)) ? true : false)); + $recips = []; + $i = $arr['obj']; + if ($i['to']) { + $arr['to'] = $i['to']; + } + if ($i['cc']) { + $arr['cc'] = $i['cc']; + } + IConfig::Set($arr, 'activitypub', 'recips', $recips); + } + + if ($arr['id']) { $post = item_store_update($arr); } @@ -3266,14 +3277,11 @@ function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $gr $arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments')); $arr['replyto'] = z_root() . '/channel/' . $channel['channel_address']; - $post = item_store($arr); + $post = item_store($arr, deliver: false, addAndSync: false); $post_id = $post['item_id']; if ($post_id) { Run::Summon([ 'Notifier','tgroup',$post_id ]); - if (!empty($post['approval_id'])) { - Run::Summon(['Notifier', 'tgroup', $post['approval_id']]); - } } q("update channel set channel_lastpost = '%s' where channel_id = %d",