[PLUGIN][ActivityPub] Notify mentions in tags

This commit is contained in:
2021-12-25 17:46:45 +00:00
parent 9d0b39e680
commit 78fddaf86a
6 changed files with 78 additions and 16 deletions

View File

@@ -380,15 +380,25 @@ class Note extends Entity
/**
* @return array of ids of Actors
*/
private array $object_mentions_ids = [];
public function setObjectMentionsIds(array $mentions): self
{
$this->object_mentions_ids = $mentions;
return $this;
}
public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null): array
{
$target_ids = [];
if (!\array_key_exists('object', $ids_already_known)) {
$mentions = Formatting::findMentions($this->getContent(), $this->getActor());
foreach ($mentions as $mention) {
foreach ($mention['mentioned'] as $m) {
$target_ids[] = $m->getId();
$target_ids = $this->object_mentions_ids ?? [];
if ($target_ids === []) {
if (!\array_key_exists('object', $ids_already_known)) {
$mentions = Formatting::findMentions($this->getContent(), $this->getActor());
foreach ($mentions as $mention) {
foreach ($mention['mentioned'] as $m) {
$target_ids[] = $m->getId();
}
}
} else {
$target_ids = $ids_already_known['object'];
}
}