[CORE][Event] Make all events return \EventResult, enforced at container build time
This commit is contained in:
@@ -34,12 +34,13 @@ use App\Entity\LocalUser;
|
||||
use App\Util\Exception\ServerException;
|
||||
use Component\FreeNetwork\FreeNetwork;
|
||||
use Component\Notification\Controller\Feed;
|
||||
use EventResult;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class Notification extends Component
|
||||
{
|
||||
public function onAddRoute(Router $m): bool
|
||||
public function onAddRoute(Router $m): EventResult
|
||||
{
|
||||
$m->connect('feed_notifications', '/feed/notifications', [Feed::class, 'notifications']);
|
||||
return Event::next;
|
||||
@@ -48,7 +49,7 @@ class Notification extends Component
|
||||
/**
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering): bool
|
||||
public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering): EventResult
|
||||
{
|
||||
DB::persist(\App\Entity\Feed::create([
|
||||
'actor_id' => $actor_id,
|
||||
@@ -75,7 +76,7 @@ class Notification extends Component
|
||||
* @param array $targets Attentions, Mentions, any other source. Should never be empty, you usually want to register an attention to every $sender->getSubscribers()
|
||||
* @param null|string $reason An optional reason explaining why this notification exists
|
||||
*/
|
||||
public function onNewNotification(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
|
||||
public function onNewNotification(Actor $sender, Activity $activity, array $targets, ?string $reason = null): EventResult
|
||||
{
|
||||
// Ensure targets are all actor objects and unique
|
||||
$effective_targets = [];
|
||||
@@ -102,13 +103,13 @@ class Notification extends Component
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
public function onQueueNotificationLocal(Actor $sender, Activity $activity, Actor $target, ?string $reason, array &$retry_args): bool
|
||||
public function onQueueNotificationLocal(Actor $sender, Activity $activity, Actor $target, ?string $reason, array &$retry_args): EventResult
|
||||
{
|
||||
// TODO: use https://symfony.com/doc/current/notifier.html
|
||||
return Event::stop;
|
||||
}
|
||||
|
||||
public function onQueueNotificationRemote(Actor $sender, Activity $activity, array $targets, ?string $reason, array &$retry_args): bool
|
||||
public function onQueueNotificationRemote(Actor $sender, Activity $activity, array $targets, ?string $reason, array &$retry_args): EventResult
|
||||
{
|
||||
if (FreeNetwork::notify($sender, $activity, $targets, $reason)) {
|
||||
return Event::stop;
|
||||
|
Reference in New Issue
Block a user