mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Update Note and CreateNote transformers, include attachment blurhash, width and height
This commit is contained in:
parent
79b378cdb1
commit
ce1afe2711
2 changed files with 26 additions and 4 deletions
|
@ -81,7 +81,8 @@ class CreateNote extends Fractal\TransformerAbstract
|
||||||
'@type' => '@id'
|
'@type' => '@id'
|
||||||
],
|
],
|
||||||
'toot' => 'http://joinmastodon.org/ns#',
|
'toot' => 'http://joinmastodon.org/ns#',
|
||||||
'Emoji' => 'toot:Emoji'
|
'Emoji' => 'toot:Emoji',
|
||||||
|
'blurhash' => 'toot:blurhash',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'id' => $status->permalink(),
|
'id' => $status->permalink(),
|
||||||
|
@ -103,12 +104,22 @@ class CreateNote extends Fractal\TransformerAbstract
|
||||||
'cc' => $status->scopeToAudience('cc'),
|
'cc' => $status->scopeToAudience('cc'),
|
||||||
'sensitive' => (bool) $status->is_nsfw,
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
|
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
|
||||||
return [
|
$res = [
|
||||||
'type' => $media->activityVerb(),
|
'type' => $media->activityVerb(),
|
||||||
'mediaType' => $media->mime,
|
'mediaType' => $media->mime,
|
||||||
'url' => $media->url(),
|
'url' => $media->url(),
|
||||||
'name' => $media->caption,
|
'name' => $media->caption,
|
||||||
];
|
];
|
||||||
|
if($media->blurhash) {
|
||||||
|
$res['blurhash'] = $media->blurhash;
|
||||||
|
}
|
||||||
|
if($media->width) {
|
||||||
|
$res['width'] = $media->width;
|
||||||
|
}
|
||||||
|
if($media->height) {
|
||||||
|
$res['height'] = $media->height;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
})->toArray(),
|
})->toArray(),
|
||||||
'tag' => $tags,
|
'tag' => $tags,
|
||||||
'commentsEnabled' => (bool) !$status->comments_disabled,
|
'commentsEnabled' => (bool) !$status->comments_disabled,
|
||||||
|
|
|
@ -82,7 +82,8 @@ class Note extends Fractal\TransformerAbstract
|
||||||
'@type' => '@id'
|
'@type' => '@id'
|
||||||
],
|
],
|
||||||
'toot' => 'http://joinmastodon.org/ns#',
|
'toot' => 'http://joinmastodon.org/ns#',
|
||||||
'Emoji' => 'toot:Emoji'
|
'Emoji' => 'toot:Emoji',
|
||||||
|
'blurhash' => 'toot:blurhash',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'id' => $status->url(),
|
'id' => $status->url(),
|
||||||
|
@ -97,12 +98,22 @@ class Note extends Fractal\TransformerAbstract
|
||||||
'cc' => $status->scopeToAudience('cc'),
|
'cc' => $status->scopeToAudience('cc'),
|
||||||
'sensitive' => (bool) $status->is_nsfw,
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
|
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
|
||||||
return [
|
$res = [
|
||||||
'type' => $media->activityVerb(),
|
'type' => $media->activityVerb(),
|
||||||
'mediaType' => $media->mime,
|
'mediaType' => $media->mime,
|
||||||
'url' => $media->url(),
|
'url' => $media->url(),
|
||||||
'name' => $media->caption,
|
'name' => $media->caption,
|
||||||
];
|
];
|
||||||
|
if($media->blurhash) {
|
||||||
|
$res['blurhash'] = $media->blurhash;
|
||||||
|
}
|
||||||
|
if($media->width) {
|
||||||
|
$res['width'] = $media->width;
|
||||||
|
}
|
||||||
|
if($media->height) {
|
||||||
|
$res['height'] = $media->height;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
})->toArray(),
|
})->toArray(),
|
||||||
'tag' => $tags,
|
'tag' => $tags,
|
||||||
'commentsEnabled' => (bool) !$status->comments_disabled,
|
'commentsEnabled' => (bool) !$status->comments_disabled,
|
||||||
|
|
Loading…
Reference in a new issue