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;
$item['isGroup'] = true;
$item['group-link'] = $item['owner-link'] = $audience;
$item['owner-id'] = Contact::getIdForURL($audience);
+ break;
}
}
} else {
$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']);
$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']), '#');
*/
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;
}
}
- $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']]);
}
/**