]> git.mxchange.org Git - friendica.git/commitdiff
Block communication with Diaspora for communities
authorMichael <heluecht@pirati.ca>
Tue, 15 Feb 2022 07:08:02 +0000 (07:08 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 15 Feb 2022 07:08:02 +0000 (07:08 +0000)
src/Model/Item.php
src/Module/Diaspora/Receive.php
src/Protocol/Diaspora.php
src/Worker/Notifier.php

index 46f41e9a93c339e1c2538c6686ec3bddb0415599..9c67426344bb8ac3b958c86eafb2bbcbd042e501 100644 (file)
@@ -818,6 +818,15 @@ class Item
                $item['inform']        = trim($item['inform'] ?? '');
                $item['file']          = trim($item['file'] ?? '');
 
+               // Communities aren't working with the Diaspora protoccol
+               if (($uid != 0) && ($item['network'] == Protocol::DIASPORA)) {
+                       $user = User::getById($uid, ['account-type']);
+                       if ($user['account-type'] == Contact::TYPE_COMMUNITY) {
+                               Logger::info('Community posts are not supported via Diaspora');
+                               return 0;
+                       }
+               }
+
                // Items cannot be stored before they happen ...
                if ($item['created'] > DateTimeFormat::utcNow()) {
                        $item['created'] = DateTimeFormat::utcNow();
index 498d1b13eda2ff14e05d1858573898f25025a4a2..19de0873ffe91a881f486cb88f449ac573c0943b 100644 (file)
@@ -93,6 +93,12 @@ class Receive extends BaseModule
 
                $importer = User::getByGuid($this->parameters['guid']);
 
+               if ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
+                       // Communities aren't working with the Diaspora protoccol
+                       // We throw an "accepted" here, so that the sender doesn't repeat the delivery
+                       throw new HTTPException\AcceptedException();
+               }
+
                $msg = $this->decodePost(false, $importer['prvkey'] ?? '');
 
                $this->logger->info('Diaspora: Dispatching.');
index aba79364f406ab41eccaffd256c77ea436f4c39a..ea0b2b6749ab9a6b83c2749a5ad26e0c6335c156 100644 (file)
@@ -858,10 +858,6 @@ class Diaspora
                } elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
                        // Yes, then it is fine.
                        return true;
-                       // Is it a post to a community?
-               } elseif (($contact["rel"] == Contact::FOLLOWER) && ($importer['account-type'] == User::ACCOUNT_TYPE_COMMUNITY)) {
-                       // That's good
-                       return true;
                        // Is the message a global user or a comment?
                } elseif (($importer["uid"] == 0) || $is_comment) {
                        // Messages for the global users and comments are always accepted
@@ -3473,9 +3469,8 @@ class Diaspora
 
        private static function prependParentAuthorMention($body, $profile_url)
        {
-               $profile = Contact::getByURL($profile_url, false, ['addr', 'name', 'contact-type']);
+               $profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
                if (!empty($profile['addr'])
-                       && $profile['contact-type'] != Contact::TYPE_COMMUNITY
                        && !strstr($body, $profile['addr'])
                        && !strstr($body, $profile_url)
                ) {
index bfd38fe01ff21a791c0c0bf53630cc7db80fdfe3..3a5c7f13e17f29a87cd4b5f6a43aeb26dd8ec207 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;