Federate attachments as Links instead of Documents
This commit is contained in:
parent
02b9436494
commit
6f0b42656d
1 changed files with 5 additions and 3 deletions
|
@ -245,8 +245,8 @@ def fix_attachments(%{"attachment" => attachment} = object) when is_list(attachm
|
||||||
"type" => Map.get(url || %{}, "type", "Link")
|
"type" => Map.get(url || %{}, "type", "Link")
|
||||||
}
|
}
|
||||||
|> Maps.put_if_present("mediaType", media_type)
|
|> Maps.put_if_present("mediaType", media_type)
|
||||||
|> Maps.put_if_present("width", (url || %{})["width"])
|
|> Maps.put_if_present("width", (url || %{})["width"] || data["width"])
|
||||||
|> Maps.put_if_present("height", (url || %{})["height"])
|
|> Maps.put_if_present("height", (url || %{})["height"] || data["height"])
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"url" => [attachment_url],
|
"url" => [attachment_url],
|
||||||
|
@ -963,7 +963,7 @@ def prepare_attachments(object) do
|
||||||
object
|
object
|
||||||
|> Map.get("attachment", [])
|
|> Map.get("attachment", [])
|
||||||
|> Enum.map(fn data ->
|
|> Enum.map(fn data ->
|
||||||
[%{"mediaType" => media_type, "href" => href} | _] = data["url"]
|
[%{"mediaType" => media_type, "href" => href} = url | _] = data["url"]
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"url" => href,
|
"url" => href,
|
||||||
|
@ -971,6 +971,8 @@ def prepare_attachments(object) do
|
||||||
"name" => data["name"],
|
"name" => data["name"],
|
||||||
"type" => "Document"
|
"type" => "Document"
|
||||||
}
|
}
|
||||||
|
|> Maps.put_if_present("width", url["width"])
|
||||||
|
|> Maps.put_if_present("height", url["height"])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Map.put(object, "attachment", attachments)
|
Map.put(object, "attachment", attachments)
|
||||||
|
|
Loading…
Reference in a new issue