/** * {@inheritdoc} */ protected function data(ServerRequestInterface $request, Document $document) { $actor = $request->getAttribute('actor'); if ($actor->isGuest()) { throw new PermissionDeniedException(); } $actor->markNotificationsAsRead()->save(); $limit = $this->extractLimit($request); $offset = $this->extractOffset($request); $include = $this->extractInclude($request); return $this->notifications->findByUser($actor, $limit, $offset)->load($include); }
/** * {@inheritdoc} */ protected function data(ServerRequestInterface $request, Document $document) { $actor = $request->getAttribute('actor'); if ($actor->isGuest()) { throw new PermissionDeniedException(); } $actor->markNotificationsAsRead()->save(); $limit = $this->extractLimit($request); $offset = $this->extractOffset($request); $include = $this->extractInclude($request); $notifications = $this->notifications->findByUser($actor, $limit, $offset)->load(array_diff($include, ['subject.discussion']))->all(); if (in_array('subject.discussion', $include)) { $this->loadSubjectDiscussions($notifications); } return $notifications; }
/** * @param ReadAllNotifications $command * @throws \Flarum\Core\Exception\PermissionDeniedException */ public function handle(ReadAllNotifications $command) { $actor = $command->actor; $this->assertRegistered($actor); $this->notifications->markAllAsRead($actor); }