[Notification][ENTITY][Activity] Avoid including sender in notification targets
This commit is contained in:
parent
93fa7eb0b5
commit
57beb178cc
@ -36,7 +36,7 @@ class Notification extends Component
|
|||||||
*/
|
*/
|
||||||
public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool
|
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);
|
$this->notify($sender, $activity, $targets, $reason);
|
||||||
|
|
||||||
return Event::next;
|
return Event::next;
|
||||||
|
@ -157,7 +157,7 @@ class Activity extends Entity
|
|||||||
*
|
*
|
||||||
* @return array of Actors
|
* @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 = [];
|
$target_ids = [];
|
||||||
|
|
||||||
@ -179,6 +179,9 @@ class Activity extends Entity
|
|||||||
if (array_key_exists('object', $ids_already_known)) {
|
if (array_key_exists('object', $ids_already_known)) {
|
||||||
array_push($target_ids, ...$ids_already_known['object']);
|
array_push($target_ids, ...$ids_already_known['object']);
|
||||||
} else {
|
} 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));
|
array_push($target_ids, ...$this->getObject()->getNotificationTargets($ids_already_known));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user