. // }}} namespace Component\Notification; use App\Core\DB\DB; use App\Core\Event; use App\Core\Log; use App\Core\Modules\Component; use App\Entity\Activity; use App\Entity\Actor; use Component\FreeNetwork\FreeNetwork; use DateTime; use DateTimeInterface; class Notification extends Component { /** * Enqueues a notification for an Actor (user or group) which means * it shows up in their home feed and such. */ public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool { $targets = $activity->getNotificationTargets($ids_already_known); foreach ($targets as $target) { $this->notify($sender, $activity, $target, $reason); } return Event::next; } public function notify(Actor $sender, Activity $activity, Actor $target, ?string $reason = null): bool { if ($target->isGroup()) { // FIXME: Make sure we check (for both local and remote) users are in the groups they send to! } else { if ($target->hasBlocked($activity->getActor())) { Log::info("Not saving reply to actor {$target->getId()} from sender {$sender->getId()} because of a block."); return false; } } if ($target->getIsLocal()) { // TODO: use https://symfony.com/doc/current/notifier.html } else { return FreeNetwork::notify($sender, $activity, $target, $reason); } return true; } }