Skip to content

Commit

Permalink
Update ap helpers, store media attachment width and height if present
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Sep 27, 2023
1 parent ce1afe2 commit 8c96919
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/Util/ActivityPub/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public static function verifyAttachments($data)
'string',
Rule::in($mimeTypes)
],
'*.name' => 'sometimes|nullable|string'
'*.name' => 'sometimes|nullable|string',
'*.blurhash' => 'sometimes|nullable|string|min:6|max:164',
'*.width' => 'sometimes|nullable|integer|min:1|max:5000',
'*.height' => 'sometimes|nullable|integer|min:1|max:5000',
])->passes();

return $valid;
Expand Down Expand Up @@ -684,6 +687,8 @@ public static function importNoteAttachment($data, Status $status)
$blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
$license = isset($media['license']) ? License::nameToId($media['license']) : null;
$caption = isset($media['name']) ? Purify::clean($media['name']) : null;
$width = isset($media['width']) ? $media['width'] : false;
$height = isset($media['height']) ? $media['height'] : false;

$media = new Media();
$media->blurhash = $blurhash;
Expand All @@ -695,6 +700,12 @@ public static function importNoteAttachment($data, Status $status)
$media->remote_url = $url;
$media->caption = $caption;
$media->order = $key + 1;
if($width) {
$media->width = $width;
}
if($height) {
$media->height = $height;
}
if($license) {
$media->license = $license;
}
Expand Down

0 comments on commit 8c96919

Please sign in to comment.