Ingest remote attachment width/height
This commit is contained in:
parent
ab9eabdf20
commit
4c060ae733
5 changed files with 50 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue