mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update NotificationService, fix 500 bug
This commit is contained in:
parent
ac6b3f07de
commit
4a609dc377
1 changed files with 18 additions and 4 deletions
|
@ -27,7 +27,10 @@ class NotificationService {
|
||||||
$ids = self::coldGet($id, $start, $stop);
|
$ids = self::coldGet($id, $start, $stop);
|
||||||
}
|
}
|
||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
$res->push(self::getNotification($id));
|
$n = self::getNotification($id);
|
||||||
|
if($n != null) {
|
||||||
|
$res->push($n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +59,10 @@ class NotificationService {
|
||||||
|
|
||||||
$res = collect([]);
|
$res = collect([]);
|
||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
$res->push(self::getNotification($id));
|
$n = self::getNotification($id);
|
||||||
|
if($n != null) {
|
||||||
|
$res->push($n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $res->toArray();
|
return $res->toArray();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +77,10 @@ class NotificationService {
|
||||||
|
|
||||||
$res = collect([]);
|
$res = collect([]);
|
||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
$res->push(self::getNotification($id));
|
$n = self::getNotification($id);
|
||||||
|
if($n != null) {
|
||||||
|
$res->push($n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $res->toArray();
|
return $res->toArray();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +138,12 @@ 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, 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 = 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());
|
||||||
|
|
Loading…
Reference in a new issue