mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update MediaService
This commit is contained in:
parent
427f9da33e
commit
450154e5af
1 changed files with 5 additions and 4 deletions
|
@ -18,12 +18,13 @@ class MediaService
|
||||||
|
|
||||||
public static function get($statusId)
|
public static function get($statusId)
|
||||||
{
|
{
|
||||||
return Cache::remember(self::CACHE_KEY.$statusId, 129600, function() use($statusId) {
|
$status = Status::find($statusId);
|
||||||
$status = Status::find($statusId);
|
$ttl = $status->created_at->lt(now()->subMinutes(30)) ? 129600 : 30;
|
||||||
|
return Cache::remember(self::CACHE_KEY.$statusId, $ttl, function() use($status) {
|
||||||
if(!$status) {
|
if(!$status) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
|
if(in_array($status->type, ['group:post', 'photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
|
||||||
$media = Media::whereStatusId($status->id)->orderBy('order')->get();
|
$media = Media::whereStatusId($status->id)->orderBy('order')->get();
|
||||||
$fractal = new Fractal\Manager();
|
$fractal = new Fractal\Manager();
|
||||||
$fractal->setSerializer(new ArraySerializer());
|
$fractal->setSerializer(new ArraySerializer());
|
||||||
|
@ -46,7 +47,7 @@ class MediaService
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return collect($status)->map(function($s) use($license) {
|
return collect($status)->map(function($s) {
|
||||||
$license = isset($s['license']) && $s['license']['title'] ? $s['license']['title'] : null;
|
$license = isset($s['license']) && $s['license']['title'] ? $s['license']['title'] : null;
|
||||||
return [
|
return [
|
||||||
'type' => 'Document',
|
'type' => 'Document',
|
||||||
|
|
Loading…
Reference in a new issue