aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-06-23 05:30:34 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-07-15 12:32:42 +0200
commitc19bdc811e526f83a2120c58f858044f4ff96e5f (patch)
tree3f98f5464675da0f7064da1b8d876f596cba4a13 /lib
parentd713930ea7fe78f705f534febe4ceaf0a0216d24 (diff)
downloadpleroma-c19bdc811e526f83a2120c58f858044f4ff96e5f.tar.gz
Fix attachments in polls
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex2
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex12
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex b/lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex
index f64fac46d..881030f38 100644
--- a/lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UrlObjectValidator do
embedded_schema do
field(:type, :string)
field(:href, ObjectValidators.Uri)
- field(:mediaType, :string)
+ field(:mediaType, :string, default: "application/octet-stream")
end
def changeset(struct, data) do
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 26325d5de..0ad982720 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -240,13 +240,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
if href do
attachment_url =
- %{"href" => href}
+ %{
+ "href" => href,
+ "type" => Map.get(url || %{}, "type", "Link")
+ }
|> Maps.put_if_present("mediaType", media_type)
- |> Maps.put_if_present("type", Map.get(url || %{}, "type"))
- %{"url" => [attachment_url]}
+ %{
+ "url" => [attachment_url],
+ "type" => data["type"] || "Document"
+ }
|> Maps.put_if_present("mediaType", media_type)
- |> Maps.put_if_present("type", data["type"])
|> Maps.put_if_present("name", data["name"])
else
nil