From 46d70541d313c836ab0c078ba6121fe5fe956e62 Mon Sep 17 00:00:00 2001 From: Yassine Doghri Date: Fri, 9 Dec 2022 16:44:59 +0000 Subject: [PATCH] fix(notifications): remove cache inconsistencies when marking notification as read --- app/Models/ActorModel.php | 11 +---------- modules/Admin/Controllers/NotificationController.php | 5 +---- modules/Fediverse/Models/ActorModel.php | 11 +---------- modules/Fediverse/Models/PostModel.php | 11 +---------- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/app/Models/ActorModel.php b/app/Models/ActorModel.php index 47b35485..b34993d9 100644 --- a/app/Models/ActorModel.php +++ b/app/Models/ActorModel.php @@ -22,15 +22,6 @@ class ActorModel extends FediverseActorModel public function getActorById(int $id): ?Actor { - $cacheName = config('Fediverse') - ->cachePrefix . "actor#{$id}"; - if (! ($found = cache($cacheName))) { - $found = $this->find($id); - - cache() - ->save($cacheName, $found, DECADE); - } - - return $found; + return $this->find($id); } } diff --git a/modules/Admin/Controllers/NotificationController.php b/modules/Admin/Controllers/NotificationController.php index ea04b6c3..54d43b79 100644 --- a/modules/Admin/Controllers/NotificationController.php +++ b/modules/Admin/Controllers/NotificationController.php @@ -85,10 +85,7 @@ class NotificationController extends BaseController $post = (new PostModel())->getPostById($this->notification->post_id); - return redirect()->route( - 'post', - [esc((new PodcastModel())->getPodcastByActorId($this->notification->actor_id)->handle), $post->id] - ); + return redirect()->route('post', [$this->podcast->handle, $post->id]); } public function markAllAsRead(): RedirectResponse diff --git a/modules/Fediverse/Models/ActorModel.php b/modules/Fediverse/Models/ActorModel.php index 3c550ddc..1d50615c 100644 --- a/modules/Fediverse/Models/ActorModel.php +++ b/modules/Fediverse/Models/ActorModel.php @@ -61,16 +61,7 @@ class ActorModel extends BaseModel public function getActorById(int $id): ?Actor { - $cacheName = config('Fediverse') - ->cachePrefix . "actor#{$id}"; - if (! ($found = cache($cacheName))) { - $found = $this->find($id); - - cache() - ->save($cacheName, $found, DECADE); - } - - return $found; + return $this->find($id); } /** diff --git a/modules/Fediverse/Models/PostModel.php b/modules/Fediverse/Models/PostModel.php index 3497e85b..2dec8b49 100644 --- a/modules/Fediverse/Models/PostModel.php +++ b/modules/Fediverse/Models/PostModel.php @@ -89,16 +89,7 @@ class PostModel extends BaseUuidModel public function getPostById(string $postId): ?Post { - $cacheName = config('Fediverse') - ->cachePrefix . "post#{$postId}"; - if (! ($found = cache($cacheName))) { - $found = $this->find($postId); - - cache() - ->save($cacheName, $found, DECADE); - } - - return $found; + return $this->find($postId); } public function getPostByUri(string $postUri): ?Post