]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Merge pull request #13330 from annando/relay-tags
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index d8cd271ea4231a58bbcafff2facd2516d1d29935..3d020a747223bf91a5e4b8c7da28e9211ba28885 100644 (file)
@@ -42,6 +42,7 @@ use Friendica\Model\Mail;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Model\Post;
+use Friendica\Moderation\Entity\Report;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\Delivery;
@@ -442,6 +443,7 @@ class Processor
                                        $item['isGroup']    = true;
                                        $item['group-link'] = $item['owner-link'] = $audience;
                                        $item['owner-id']   = Contact::getIdForURL($audience);
+                                       break;
                                }
                        }
                } else {
@@ -902,6 +904,19 @@ class Processor
                        $item['raw-body'] = $item['body'] = $content;
                }
 
+               if (!empty($item['author-id']) && ($item['author-id'] == $item['owner-id'])) {
+                       foreach (Tag::getFromBody($item['body'], Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]) as $tag) {
+                               $actor = APContact::getByURL($tag[2], false);
+                               if (($actor['type'] ?? 'Person') == 'Group') {
+                                       Logger::debug('Group post detected via exclusive mention.', ['mention' => $actor['url'], 'actor' => $activity['actor'], 'author' => $activity['author']]);
+                                       $item['isGroup']    = true;
+                                       $item['group-link'] = $item['owner-link'] = $actor['url'];
+                                       $item['owner-id']   = Contact::getIdForURL($actor['url']);
+                                       break;
+                               }
+                       }
+               }
+
                self::storeFromBody($item);
                self::storeTags($item['uri-id'], $activity['tags']);
 
@@ -1643,7 +1658,7 @@ class Processor
                $tags = Receiver::processTags(JsonLD::fetchElementArray($activity['as:object'], 'as:tag') ?? []);
                if (!empty($tags)) {
                        foreach ($tags as $tag) {
-                               if ($tag['type'] != 'Hashtag') {
+                               if (($tag['type'] != 'Hashtag') && !strpos($tag['type'], ':Hashtag')) {
                                        continue;
                                }
                                $messageTags[] = ltrim(mb_strtolower($tag['name']), '#');
@@ -1879,8 +1894,8 @@ class Processor
         */
        public static function ReportAccount(array $activity)
        {
-               $account_id = Contact::getIdForURL($activity['object_id']);
-               if (empty($account_id)) {
+               $account = Contact::getByURL($activity['object_id'], null, ['id', 'gsid']);
+               if (empty($account)) {
                        Logger::info('Unknown account', ['activity' => $activity]);
                        Queue::remove($activity);
                        return;
@@ -1901,10 +1916,10 @@ class Processor
                        }
                }
 
-               $report = DI::reportFactory()->createFromReportsRequest($reporter_id, $account_id, $activity['content'], null, '', false, $uri_ids);
+               $report = DI::reportFactory()->createFromReportsRequest(System::getRules(true), $reporter_id, $account['id'], $account['gsid'], $activity['content'], 'other', false, $uri_ids);
                DI::report()->save($report);
 
-               Logger::info('Stored report', ['reporter' => $reporter_id, 'account_id' => $account_id, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]);
+               Logger::info('Stored report', ['reporter' => $reporter_id, 'account' => $account, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]);
        }
 
        /**