Skip to content

Commit

Permalink
Update Note and CreateNote transformers, include attachment blurhash,…
Browse files Browse the repository at this point in the history
… width and height
  • Loading branch information
dansup committed Sep 27, 2023
1 parent 79b378c commit ce1afe2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions app/Transformer/ActivityPub/Verb/CreateNote.php
Expand Up @@ -81,7 +81,8 @@ public function transform(Status $status)
'@type' => '@id'
],
'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji'
'Emoji' => 'toot:Emoji',
'blurhash' => 'toot:blurhash',
]
],
'id' => $status->permalink(),
Expand All @@ -103,12 +104,22 @@ public function transform(Status $status)
'cc' => $status->scopeToAudience('cc'),
'sensitive' => (bool) $status->is_nsfw,
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
return [
$res = [
'type' => $media->activityVerb(),
'mediaType' => $media->mime,
'url' => $media->url(),
'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(),
'tag' => $tags,
'commentsEnabled' => (bool) !$status->comments_disabled,
Expand Down
15 changes: 13 additions & 2 deletions app/Transformer/ActivityPub/Verb/Note.php
Expand Up @@ -82,7 +82,8 @@ public function transform(Status $status)
'@type' => '@id'
],
'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji'
'Emoji' => 'toot:Emoji',
'blurhash' => 'toot:blurhash',
]
],
'id' => $status->url(),
Expand All @@ -97,12 +98,22 @@ public function transform(Status $status)
'cc' => $status->scopeToAudience('cc'),
'sensitive' => (bool) $status->is_nsfw,
'attachment' => $status->media()->orderBy('order')->get()->map(function ($media) {
return [
$res = [
'type' => $media->activityVerb(),
'mediaType' => $media->mime,
'url' => $media->url(),
'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(),
'tag' => $tags,
'commentsEnabled' => (bool) !$status->comments_disabled,
Expand Down

0 comments on commit ce1afe2

Please sign in to comment.