Fix attachments in polls

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-06-23 05:30:34 +02:00
commit c19bdc811e
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
6 changed files with 145 additions and 10 deletions

View file

@ -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

View file

@ -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