projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
maintenance: dependency upgrade (#81)
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
object_validators
/
attachment_validator.ex
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 837787b9fcd3955583d1121823cc84e1ccb3c1b8..ffdb16976f30263fc71b7f7dea9592eff4d5b4e3 100644
(file)
--- a/
lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex
+++ b/
lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex
@@
-44,9
+44,9
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
struct
|> cast(data, [:type, :mediaType, :name, :blurhash])
struct
|> cast(data, [:type, :mediaType, :name, :blurhash])
- |> cast_embed(:url, with: &url_changeset/2)
+ |> cast_embed(:url, with: &url_changeset/2
, required: true
)
|> validate_inclusion(:type, ~w[Link Document Audio Image Video])
|> validate_inclusion(:type, ~w[Link Document Audio Image Video])
- |> validate_required([:type, :mediaType
, :url
])
+ |> validate_required([:type, :mediaType])
end
def url_changeset(struct, data) do
end
def url_changeset(struct, data) do
@@
-68,12
+68,14
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
end
end
end
end
- defp handle_href(href, mediaType) do
+ defp handle_href(href, mediaType
, data
) do
[
%{
"href" => href,
"type" => "Link",
[
%{
"href" => href,
"type" => "Link",
- "mediaType" => mediaType
+ "mediaType" => mediaType,
+ "width" => data["width"],
+ "height" => data["height"]
}
]
end
}
]
end
@@
-81,10
+83,10
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
defp fix_url(data) do
cond do
is_binary(data["url"]) ->
defp fix_url(data) do
cond do
is_binary(data["url"]) ->
- Map.put(data, "url", handle_href(data["url"], data["mediaType"]))
+ Map.put(data, "url", handle_href(data["url"], data["mediaType"]
, data
))
is_binary(data["href"]) and data["url"] == nil ->
is_binary(data["href"]) and data["url"] == nil ->
- Map.put(data, "url", handle_href(data["href"], data["mediaType"]))
+ Map.put(data, "url", handle_href(data["href"], data["mediaType"]
, data
))
true ->
data
true ->
data
@@
-94,6
+96,6
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
defp validate_data(cng) do
cng
|> validate_inclusion(:type, ~w[Document Audio Image Video])
defp validate_data(cng) do
cng
|> validate_inclusion(:type, ~w[Document Audio Image Video])
- |> validate_required([:mediaType, :
url, :
type])
+ |> validate_required([:mediaType, :type])
end
end
end
end