This commit is contained in:
Pierre Jaury 2018-08-16 04:29:30 +02:00
commit 0c90178eaf
3 changed files with 4 additions and 4 deletions

View File

@ -125,13 +125,15 @@ class Profile extends Model
public function avatar()
{
return $this->hasOne(Avatar::class);
return $this->hasOne(Avatar::class)->withDefault([
'media_path' => 'public/avatars/default.png'
]);
}
public function avatarUrl()
{
$url = Cache::remember("avatar:{$this->id}", 1440, function() {
$path = $this->avatar->media_path ?? 'public/avatars/default.png';
$path = optional($this->avatar)->media_path;
$version = hash('sha1', $this->avatar->created_at);
$path = "{$path}?v={$version}";
return url(Storage::url($path));

View File

@ -50,7 +50,6 @@ class ProfileOutbox extends Fractal\TransformerAbstract
'sensitive' => (bool) $i->is_nsfw,
'atomUri' => $i->url(),
'inReplyToAtomUri' => null,
'conversation' => $i->url(),
'attachment' => [
// TODO: support more than 1 attachment

View File

@ -46,7 +46,6 @@ class StatusTransformer extends Fractal\TransformerAbstract
'sensitive' => (bool) $status->is_nsfw,
'atomUri' => $status->url(),
'inReplyToAtomUri' => null,
'conversation' => $status->url(),
'attachment' => $status->media->map(function($media) {
return [
'type' => 'Document',