1
0
Fork 0
forked from mirror/pixelfed

Update NotificationService, fix 500 bug

This commit is contained in:
Daniel Supernault 2021-09-19 23:05:56 -06:00
parent ac6b3f07de
commit 4a609dc377
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -27,7 +27,10 @@ class NotificationService {
$ids = self::coldGet($id, $start, $stop);
}
foreach($ids as $id) {
$res->push(self::getNotification($id));
$n = self::getNotification($id);
if($n != null) {
$res->push($n);
}
}
return $res;
}
@ -56,7 +59,10 @@ class NotificationService {
$res = collect([]);
foreach($ids as $id) {
$res->push(self::getNotification($id));
$n = self::getNotification($id);
if($n != null) {
$res->push($n);
}
}
return $res->toArray();
}
@ -71,7 +77,10 @@ class NotificationService {
$res = collect([]);
foreach($ids as $id) {
$res->push(self::getNotification($id));
$n = self::getNotification($id);
if($n != null) {
$res->push($n);
}
}
return $res->toArray();
}
@ -129,7 +138,12 @@ class NotificationService {
public static function getNotification($id)
{
return Cache::remember('service:notification:'.$id, now()->addDays(3), function() use($id) {
$n = Notification::with('item')->findOrFail($id);
$n = Notification::with('item')->find($id);
if(!$n) {
return null;
}
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($n, new NotificationTransformer());