diff --git a/mod/item.php b/mod/item.php index 56f27a9543..7d565bc35b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -40,6 +40,7 @@ use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\APContact; use Friendica\Model\Attach; use Friendica\Model\Contact; use Friendica\Model\Conversation; @@ -435,21 +436,27 @@ 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; - $str_group_allow = ''; - $str_contact_deny = ''; - $str_group_deny = ''; - if ($private_forum) { - $str_contact_allow = '<' . $private_id . '>'; - } else { - $str_contact_allow = ''; + if ($only_to_forum) { + $postopts = ''; + } + + if ($private_forum || !APContact::getByURL($forum_contact['url'])) { + $str_group_allow = ''; + $str_contact_deny = ''; + $str_group_deny = ''; + if ($private_forum) { + $str_contact_allow = '<' . $private_id . '>'; + } else { + $str_contact_allow = ''; + } + $contact_id = $private_id; + $contact_record = $forum_contact; + $_REQUEST['origin'] = false; + $wall = 0; } - $contact_id = $private_id; - $contact_record = $forum_contact; - $_REQUEST['origin'] = false; - $wall = 0; } /* diff --git a/src/Model/Item.php b/src/Model/Item.php index 2b57557ca8..f85bce5e8f 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1061,7 +1061,7 @@ class Item } // Create Diaspora signature - if ($item['origin'] && empty($item['diaspora_signed_text'])) { + if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) { $signed = Diaspora::createCommentSignature($uid, $item); if (!empty($signed)) { $item['diaspora_signed_text'] = json_encode($signed); @@ -1227,13 +1227,10 @@ class Item Logger::info('The resharer is no forum: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]); return; } - self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]); - Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]); - return; } - self::update(['owner-id' => $item['author-id'], 'contact-id' => $cid], ['id' => $parent['id']]); - Logger::info('Change owner of the parent', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $cid]); + self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]); + Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]); } /** @@ -1922,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/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index c093cc9ca6..046c6de8c3 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -20,8 +20,10 @@ use Friendica\Model\Item; use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\User; +use Friendica\Model\Verb; use Friendica\Module\Contact as ModuleContact; use Friendica\Module\Security\Login; +use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; class Network extends BaseModule @@ -388,7 +390,9 @@ class Network extends BaseModule if (self::$groupId) { $conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]); } elseif (self::$forumContactId) { - $conditionFields['contact-id'] = self::$forumContactId; + $conditionStrings = DBA::mergeConditions($conditionStrings, + ["((`contact-id` = ?) OR EXISTS(SELECT `uri-id` FROM `post-user-view` WHERE `post-user-view`.`parent-uri-id` = `network-thread-view`.`uri-id` AND (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))", + self::$forumContactId, self::$forumContactId, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]); } // Currently only the order modes "received" and "commented" are in use 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;