From 734b30e59adadfc91238cb9fca738669d5d79b9e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 21 Jul 2022 20:12:07 -0600 Subject: [PATCH] Fix NotificationService bug returning html response on /api/v1/notifications endpoint when a notification id belonging to a deleted account is rendered by checking AccountService before NotificationTransformer. --- app/Services/NotificationService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index f8d9a62e8..51ff829cb 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -203,13 +203,19 @@ class NotificationService { public static function getNotification($id) { - return Cache::remember('service:notification:'.$id, now()->addDays(3), function() use($id) { + return Cache::remember('service:notification:'.$id, 86400, function() use($id) { $n = Notification::with('item')->find($id); if(!$n) { return null; } + $account = AccountService::get($n->actor_id, true); + + if(!$account) { + return null; + } + $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $resource = new Fractal\Resource\Item($n, new NotificationTransformer());