瀏覽代碼

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.

Daniel Supernault 3 年之前
父節點
當前提交
734b30e59a
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      app/Services/NotificationService.php

+ 7 - 1
app/Services/NotificationService.php

@@ -203,13 +203,19 @@ class NotificationService {
 
 
 	public static function getNotification($id)
 	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);
 			$n = Notification::with('item')->find($id);
 
 
 			if(!$n) {
 			if(!$n) {
 				return null;
 				return null;
 			}
 			}
 
 
+			$account = AccountService::get($n->actor_id, true);
+
+			if(!$account) {
+				return null;
+			}
+
 			$fractal = new Fractal\Manager();
 			$fractal = new Fractal\Manager();
 			$fractal->setSerializer(new ArraySerializer());
 			$fractal->setSerializer(new ArraySerializer());
 			$resource = new Fractal\Resource\Item($n, new NotificationTransformer());
 			$resource = new Fractal\Resource\Item($n, new NotificationTransformer());