}
// Special treatment for forum posts
- if (Item::isForumPost($target_item, $owner)) {
+ if (Item::isForumPost($target_item['uri-id'])) {
$relay_to_owner = true;
$direct_forum_delivery = true;
}
// Avoid that comments in a forum thread are sent to OStatus
- if (Item::isForumPost($parent, $owner)) {
+ if (Item::isForumPost($parent['uri-id'])) {
$direct_forum_delivery = true;
}
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
- $contacts = DBA::toArray(DBA::select('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol'], $condition));
+ $contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol'], $condition);
$conversants = array_merge($contacts, $participants);
}
while($contact = DBA::fetch($contacts_stmt)) {
- Protocol::terminateFriendship($owner, $contact, true);
+ Contact::terminateFriendship($contact);
}
DBA::close($contacts_stmt);
$uid = $target_item['contact-uid'] ?: $target_item['uid'];
+ // Update the locally stored follower list when we deliver to a forum
+ foreach (Tag::getByURIId($target_item['uri-id'], [Tag::MENTION, Tag::EXCLUSIVE_MENTION]) as $tag) {
+ $target_contact = Contact::getByURL(Strings::normaliseLink($tag['url']), null, [], $uid);
+ if ($target_contact && $target_contact['contact-type'] == Contact::TYPE_COMMUNITY && $target_contact['manually-approve']) {
+ Group::updateMembersForForum($target_contact['id']);
+ }
+ }
+
if ($target_item['origin']) {
$inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid);
}
Logger::info('Origin item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.');
- } elseif (Item::isForumPost($target_item, $owner)) {
- $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid, false, 0, true);
- Logger::info('Forum item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.');
} elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) {
Logger::info('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.');
return ['count' => 0, 'contacts' => []];