From e2b8d5379b1ed0dc17bcf186c969b136c1f49b15 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 5 Jun 2021 18:38:21 +0000 Subject: [PATCH] Public forums are now posting unlisted --- mod/item.php | 4 ++-- src/Model/Item.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 7 ++++++- src/Worker/Notifier.php | 10 ++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mod/item.php b/mod/item.php index a8870d6865..7d565bc35b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -436,8 +436,8 @@ function item_post(App $a) { $original_contact_id = $contact_id; if (!$toplevel_item_id && !empty($forum_contact) && ($private_forum || $only_to_forum)) { - // we tagged a forum in a top level post. Now we change the post - $private = $private_forum; + // we tagged a forum in a top level post. Now we change the post + $private = $private_forum ? Item::PRIVATE : Item::UNLISTED; if ($only_to_forum) { $postopts = ''; diff --git a/src/Model/Item.php b/src/Model/Item.php index f6bec1561c..f85bce5e8f 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1919,7 +1919,7 @@ class Item // also reset all the privacy bits to the forum default permissions - $private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? self::PRIVATE : self::PUBLIC; + $private = ($user['allow_cid'] || $user['allow_gid'] || $user['deny_cid'] || $user['deny_gid']) ? self::PRIVATE : self::UNLISTED; $psid = PermissionSet::getIdFromACL( $user['uid'], diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index bfb1287c82..76bc295d1c 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -533,6 +533,8 @@ class Transmitter $actor_profile = APContact::getByURL($item['author-link']); } + $exclusive = false; + $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); if ($item['private'] != Item::PRIVATE) { @@ -557,6 +559,9 @@ class Transmitter foreach ($terms as $term) { $profile = APContact::getByURL($term['url'], false); if (!empty($profile)) { + if ($term['type'] == Tag::EXCLUSIVE_MENTION) { + $exclusive = true; + } $data['to'][] = $profile['url']; } } @@ -612,7 +617,7 @@ class Transmitter $data['cc'][] = $actor_profile['followers']; } } - } else { + } elseif (!$exclusive) { // Public thread parent post always are directed to the followers if (($item['private'] != Item::PRIVATE) && !$forum_mode) { $data['cc'][] = $actor_profile['followers']; diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index de2774594d..4af1bc9148 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -283,6 +283,16 @@ class Notifier } Logger::log('Notify ' . $target_item["guid"] .' via PuSH: ' . ($push_notify ? "Yes":"No"), Logger::DEBUG); + } elseif ($targets = Tag::getByURIId($target_item['uri-id'], [Tag::EXCLUSIVE_MENTION])) { + $followup = true; + + foreach ($targets as $target) { + $cid = Contact::getIdForURL($target['url'], $uid, false); + if ($cid) { + $recipients_followup[] = $cid; + Logger::info('Exclusively delivering', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'url' => $target['url']]); + } + } } else { $followup = false;