2 && !$mid) { $mid = intval(argv(1)); $action = argv(2); } elseif (argc() == 2 && $mid) { $action = argv(1); } $post_id = $mid; if ($action) { if (!$post_id) { goaway(z_root() . '/moderate'); } $r = q( "select * from item where uid = %d and id = %d and item_blocked = %d limit 1", intval(local_channel()), intval($post_id), intval(ITEM_MODERATED) ); if ($r) { $item = $r[0]; if ($action === 'approve') { q( "update item set item_blocked = 0 where uid = %d and id = %d", intval(local_channel()), intval($post_id) ); $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); notice(t('Comment deleted') . EOL); } // refetch the item after changes have been made $r = q( "select * from item where id = %d", intval($post_id) ); if ($r) { xchan_query($r); $sync_item = fetch_post_tags($r); Libsync::build_sync_packet(local_channel(), ['item' => [encode_item($sync_item[0], true)]]); } if ($action === 'approve') { if ($item['id'] !== $item['parent']) { // if this is a group comment, call tag_deliver() to generate the associated // Announce activity so microblog destinations will see it in their home timeline $role = get_pconfig(local_channel(), 'system', 'permissions_role'); $rolesettings = PermissionRoles::role_perms($role); $channel_type = $rolesettings['channel_type'] ?? 'normal'; $is_group = $channel_type === 'group'; if ($is_group) { tag_deliver(local_channel(), $post_id); } } Run::Summon(['Notifier', 'comment-new', $post_id]); } goaway(z_root() . '/moderate'); } } if ($r) { xchan_query($r); $items = fetch_post_tags($r); } else { $items = []; } $o = conversation($items, 'moderate', false); $o .= alt_pager(count($items)); return $o; } }