Store the receivers of a post in the tags

This commit is contained in:
Michael 2022-02-19 13:31:49 +00:00
parent c03ff7833b
commit c867581530
7 changed files with 173 additions and 78 deletions

View file

@ -526,6 +526,8 @@ class Processor
self::storeFromBody($item);
self::storeTags($item['uri-id'], $activity['tags']);
self::storeReceivers($item['uri-id'], $activity['receiver_urls'] ?? []);
$item['location'] = $activity['location'];
if (!empty($activity['latitude']) && !empty($activity['longitude'])) {
@ -756,6 +758,22 @@ class Processor
}
}
public static function storeReceivers(int $uriid, array $receivers)
{
foreach (['as:to' => Tag::TO, 'as:cc' => Tag::CC, 'as:bto' => Tag::BTO, 'as:bcc' => Tag::BCC] as $element => $type) {
if (!empty($receivers[$element])) {
foreach ($receivers[$element] as $receiver) {
if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
$name = Receiver::PUBLIC_COLLECTION;
} else {
$name = trim(parse_url($receiver, PHP_URL_PATH), '/');
}
Tag::store($uriid, $type, $name, $receiver);
}
}
}
}
/**
* Creates an mail post
*