diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-05-12 15:38:49 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-05-12 15:38:49 -0500 |
commit | 4c060ae73371a8567468186e5d1333ec00fbdf41 (patch) | |
tree | 42a2ad7937cee659464574f428283cc75f7245ad /lib | |
parent | ab9eabdf20180f2dd8539cf5d3dc0fdc6412496b (diff) | |
download | pleroma-4c060ae73371a8567468186e5d1333ec00fbdf41.tar.gz pleroma-4c060ae73371a8567468186e5d1333ec00fbdf41.zip |
Ingest remote attachment width/height
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex b/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex index 3175427ad..a99b40adc 100644 --- a/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex @@ -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 diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 4d9a5617e..b5767863c 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -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], |