]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Merge pull request #11341 from tobiasd/20220315-getcontactstoupdate
[friendica.git] / src / Worker / Notifier.php
index bfd38fe01ff21a791c0c0bf53630cc7db80fdfe3..80628d7dba08d08fe5e55a3dabc84886e2a27038 100644 (file)
@@ -153,7 +153,7 @@ class Notifier
                }
 
                // Should the post be transmitted to Diaspora?
-               $diaspora_delivery = true;
+               $diaspora_delivery = ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY);
 
                // If this is a public conversation, notify the feed hub
                $public_message = true;
@@ -235,13 +235,13 @@ class Notifier
                        }
 
                        // 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;
                        }
 
@@ -445,7 +445,7 @@ class Notifier
                        $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);
 
@@ -673,7 +673,7 @@ class Notifier
                }
 
                while($contact = DBA::fetch($contacts_stmt)) {
-                       Protocol::terminateFriendship($owner, $contact, true);
+                       Contact::terminateFriendship($contact);
                }
                DBA::close($contacts_stmt);
 
@@ -729,6 +729,14 @@ class Notifier
 
                $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);
 
@@ -738,9 +746,6 @@ class Notifier
                        }
 
                        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' => []];