summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-03-19 15:08:49 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-03-19 15:39:11 +0100
commitf9d622d25a744f58fbaf8370ad4435597bb15bf0 (patch)
treed389edc6f292a2573303e69a99bc90a53f227039
parentd3cf7e19fbe089b3a6d62d6a26f3dfc866a6669d (diff)
downloadpleroma-f9d622d25a744f58fbaf8370ad4435597bb15bf0.tar.gz
pleroma-f9d622d25a744f58fbaf8370ad4435597bb15bf0.zip
WIP
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex15
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs18
2 files changed, 14 insertions, 19 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 9cd3de705..db848f657 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -202,21 +202,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> Map.put("conversation", context)
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
object
|> Map.put("attachment", [attachment])
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index 2bd494a37..01c955c0a 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -1250,7 +1250,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
assert object["name"] == desc
assert object["type"] == "Document"
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 = %{
"@context" => "https://www.w3.org/ns/activitystreams",
@@ -1274,11 +1276,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
assert activity_response["object"]
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["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
conn