]> git.mxchange.org Git - friendica.git/commitdiff
Don't accept ignored author via relay
authorMichael <heluecht@pirati.ca>
Fri, 2 Oct 2020 03:35:22 +0000 (03:35 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 2 Oct 2020 03:35:22 +0000 (03:35 +0000)
src/Protocol/ActivityPub/Processor.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/Relay.php

index ab1b27d331557cdc52d34504fb297bd7c33f5123..c7310d9eb8d1f824038a617858e55337ee2f48ff 100644 (file)
@@ -806,6 +806,9 @@ class Processor
                        return true;
                }
 
+               $attributed_to = JsonLD::fetchElement($activity['as:object'], 'as:attributedTo', '@id');
+               $authorid = Contact::getIdForURL($attributed_to);
+
                $body = HTML::toBBCode(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value'));
 
                $messageTags = [];
@@ -819,7 +822,7 @@ class Processor
                        }
                }
 
-               return Relay::isSolicitedPost($messageTags, $body, $id, Protocol::ACTIVITYPUB);
+               return Relay::isSolicitedPost($messageTags, $body, $authorid, $id, Protocol::ACTIVITYPUB);
        }
 
        /**
index 0b763d1aa3f528d9152977dc491a82cc2b26f7ff..4ba6aa2a25993b2fb1832ada6f6b72e3533ac787 100644 (file)
@@ -2277,7 +2277,7 @@ class DFRN
 
                $taglist = Tag::getByURIId($item['uri-id'], [Tag::HASHTAG]);
                $tags = array_column($taglist, 'name');
-               return Relay::isSolicitedPost($tags, $item['body'], $item['uri'], Protocol::DFRN);
+               return Relay::isSolicitedPost($tags, $item['body'], $item['author-id'], $item['uri'], Protocol::DFRN);
        }
 
        /**
index 6b2bd9f70aa7bc777a2b3eff7e1ddb1dba32579a..fd668b1f3062755103630af9837da3eb7d053947 100644 (file)
@@ -2807,7 +2807,7 @@ class Diaspora
 
                $taglist = Tag::getByURIId($uriid, [Tag::HASHTAG]);
                $tags = array_column($taglist, 'name');
-               return Relay::isSolicitedPost($tags, $body, $url, Protocol::DIASPORA);
+               return Relay::isSolicitedPost($tags, $body, $contact['id'], $url, Protocol::DIASPORA);
        }
 
        /**
index 3184528cc56213f4627f4f6d8a992e80e33bdb1e..fb838f91761b7b2f0f1cbe46da5aa20178a54dfa 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Protocol;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Logger;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Model\Search;
 
 /**
@@ -36,10 +37,11 @@ class Relay
         *
         * @param array $tags
         * @param string $body
+        * @param int $authorid
         * @param string $url
         * @return boolean "true" is the post is wanted by the system
         */
-       public static function isSolicitedPost(array $tags, string $body, string $url, string $network = '')
+       public static function isSolicitedPost(array $tags, string $body, int $authorid, string $url, string $network = '')
        {
                $config = DI::config();
 
@@ -55,6 +57,16 @@ class Relay
                        return false;
                }
 
+               if (Contact::isBlocked($authorid)) {
+                       Logger::info('Author is blocked - rejected', ['author' => $authorid, 'network' => $network, 'url' => $url]);
+                       return false;
+               }
+
+               if (Contact::isHidden($authorid)) {
+                       Logger::info('Author is hidden - rejected', ['author' => $authorid, 'network' => $network, 'url' => $url]);
+                       return false;
+               }
+
                $systemTags = [];
                $userTags = [];
                $denyTags = [];