mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update Status, generate missing status types
This commit is contained in:
parent
ad5d6b9977
commit
b7362caf50
3 changed files with 8 additions and 14 deletions
|
@ -53,30 +53,24 @@ class Status extends Model
|
|||
// todo: deprecate after 0.6.0
|
||||
public function viewType()
|
||||
{
|
||||
return Cache::remember('status:view-type:'.$this->id, 10080, function() {
|
||||
$this->setType();
|
||||
$media = $this->firstMedia();
|
||||
$mime = explode('/', $media->mime)[0];
|
||||
$count = $this->media()->count();
|
||||
$type = ($mime == 'image') ? 'image' : 'video';
|
||||
if($count > 1) {
|
||||
$type = ($type == 'image') ? 'album' : 'video-album';
|
||||
}
|
||||
return $type;
|
||||
});
|
||||
if($this->type) {
|
||||
return $this->type;
|
||||
}
|
||||
return $this->setType();
|
||||
}
|
||||
|
||||
// todo: deprecate after 0.6.0
|
||||
public function setType()
|
||||
{
|
||||
if(in_array($this->type, self::STATUS_TYPES)) {
|
||||
return;
|
||||
return $this->type;
|
||||
}
|
||||
$mimes = $this->media->pluck('mime')->toArray();
|
||||
$type = StatusController::mimeTypeCheck($mimes);
|
||||
if($type) {
|
||||
$this->type = $type;
|
||||
$this->save();
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
|||
'language' => null,
|
||||
'pinned' => null,
|
||||
|
||||
'pf_type' => $status->type,
|
||||
'pf_type' => $status->type ?? $status->setType(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ return [
|
|||
| This value is the version of your PixelFed instance.
|
||||
|
|
||||
*/
|
||||
'version' => '0.5.0',
|
||||
'version' => '0.5.1',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue