getPodcastById((int) $params[0])) instanceof Podcast ) { throw PageNotFoundException::forPageNotFound(); } $params[0] = $podcast; if (count($params) > 1) { if ( ! ($notification = (new NotificationModel())->find($params[1])) instanceof Notification ) { throw PageNotFoundException::forPageNotFound(); } $params[1] = $notification; } return $this->{$method}(...$params); } public function list(Podcast $podcast): string { $notifications = (new NotificationModel())->where('target_actor_id', $podcast->actor_id) ->orderBy('created_at', 'desc'); $data = [ 'podcast' => $podcast, 'notifications' => $notifications->paginate(10), 'pager' => $notifications->pager, ]; $this->setHtmlHead(lang('Notifications.title')); replace_breadcrumb_params([ 0 => $podcast->at_handle, ]); return view('podcast/notifications', $data); } public function markAllAsReadAction(Podcast $podcast): RedirectResponse { $notifications = (new NotificationModel())->where('target_actor_id', $podcast->actor_id) ->where('read_at', null) ->findAll(); foreach ($notifications as $notification) { $notification->read_at = new Time('now'); (new NotificationModel())->update($notification->id, $notification); } return redirect()->back(); } public function markAsReadAction(Podcast $podcast, Notification $notification): RedirectResponse { $notification->read_at = new Time('now'); $notificationModel = new NotificationModel(); $notificationModel->update($notification->id, $notification); if ($notification->post_id === null) { return redirect()->route('podcast-activity', [esc($podcast->handle)]); } $post = (new PostModel())->getPostById($notification->post_id); return redirect()->route('post', [$podcast->handle, $post->id]); } }