[Notification][ENTITY][Activity] Avoid including sender in notification targets

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-12 06:38:07 +00:00
parent 93fa7eb0b5
commit 57beb178cc
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 5 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class Notification extends Component
*/
public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool
{
$targets = $activity->getNotificationTargets($ids_already_known);
$targets = $activity->getNotificationTargets($ids_already_known, sender_id: $sender->getId());
$this->notify($sender, $activity, $targets, $reason);
return Event::next;

View File

@ -157,7 +157,7 @@ class Activity extends Entity
*
* @return array of Actors
*/
public function getNotificationTargets(array $ids_already_known = []): array
public function getNotificationTargets(array $ids_already_known = [], ?int $sender_id = null): array
{
$target_ids = [];
@ -179,6 +179,9 @@ class Activity extends Entity
if (array_key_exists('object', $ids_already_known)) {
array_push($target_ids, ...$ids_already_known['object']);
} else {
if (!is_null($author = $this->getObject()?->getActorId()) && $author !== $sender_id) {
$target_ids[] = $this->getObject()->getActorId();
}
array_push($target_ids, ...$this->getObject()->getNotificationTargets($ids_already_known));
}