Ingest remote attachment width/height

This commit is contained in:
Alex Gleason 2021-05-12 15:38:49 -05:00
commit 4c060ae733
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 50 additions and 5 deletions

View file

@ -21,6 +21,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
field(:type, :string)
field(:href, ObjectValidators.Uri)
field(:mediaType, :string, default: "application/octet-stream")
field(:width, :integer)
field(:height, :integer)
end
end
@ -52,7 +54,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
data = fix_media_type(data)
struct
|> cast(data, [:type, :href, :mediaType])
|> cast(data, [:type, :href, :mediaType, :width, :height])
|> validate_inclusion(:type, ["Link"])
|> validate_required([:type, :href, :mediaType])
end

View file

@ -245,6 +245,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
"type" => Map.get(url || %{}, "type", "Link")
}
|> Maps.put_if_present("mediaType", media_type)
|> Maps.put_if_present("width", (url || %{})["width"])
|> Maps.put_if_present("height", (url || %{})["height"])
%{
"url" => [attachment_url],