mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-03 18:23:54 +00:00
WIP
This commit is contained in:
parent
d3cf7e19fb
commit
f9d622d25a
|
@ -202,21 +202,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|> Map.put("conversation", context)
|
|> Map.put("conversation", context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_attachments(%{"attachment" => attachment} = object) when is_list(attachment) do
|
|
||||||
attachments =
|
|
||||||
Enum.map(attachment, fn data ->
|
|
||||||
media_type = data["mediaType"] || data["mimeType"]
|
|
||||||
href = data["url"] || data["href"]
|
|
||||||
url = [%{"type" => "Link", "mediaType" => media_type, "href" => href}]
|
|
||||||
|
|
||||||
data
|
|
||||||
|> Map.put("mediaType", media_type)
|
|
||||||
|> Map.put("url", url)
|
|
||||||
end)
|
|
||||||
|
|
||||||
Map.put(object, "attachment", attachments)
|
|
||||||
end
|
|
||||||
|
|
||||||
def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachment) do
|
def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachment) do
|
||||||
object
|
object
|
||||||
|> Map.put("attachment", [attachment])
|
|> Map.put("attachment", [attachment])
|
||||||
|
|
|
@ -1250,7 +1250,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
assert object["name"] == desc
|
assert object["name"] == desc
|
||||||
assert object["type"] == "Document"
|
assert object["type"] == "Document"
|
||||||
assert object["actor"] == user.ap_id
|
assert object["actor"] == user.ap_id
|
||||||
assert [%{"href" => object_href}] = object["url"]
|
assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
|
||||||
|
assert is_binary(object_href)
|
||||||
|
assert object_mediatype == "image/jpeg"
|
||||||
|
|
||||||
activity_request = %{
|
activity_request = %{
|
||||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
|
@ -1274,11 +1276,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
assert activity_response["object"]
|
assert activity_response["object"]
|
||||||
assert activity_response["actor"] == user.ap_id
|
assert activity_response["actor"] == user.ap_id
|
||||||
|
|
||||||
assert %Object{data: %{"attachment" => [attachment]}} = Object.normalize(activity_response["object"])
|
assert %Object{data: %{"attachment" => [attachment]}} =
|
||||||
|
Object.normalize(activity_response["object"])
|
||||||
|
|
||||||
assert attachment["type"] == "Document"
|
assert attachment["type"] == "Document"
|
||||||
assert attachment["name"] == desc
|
assert attachment["name"] == desc
|
||||||
assert [%{"href" => attachment_href}] = attachment["url"]
|
|
||||||
assert attachment_href == object_href
|
assert [
|
||||||
|
%{
|
||||||
|
"href" => ^object_href,
|
||||||
|
"type" => "Link",
|
||||||
|
"mediaType" => ^object_mediatype
|
||||||
|
}
|
||||||
|
] = attachment["url"]
|
||||||
|
|
||||||
# Fails if unauthenticated
|
# Fails if unauthenticated
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in a new issue