From 71eff09e564ae3eeaf02acecbb8d89b7d4e2e511 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 28 Sep 2019 12:12:35 +0000 Subject: [PATCH] common api: make sure the generated IR is actually federatable --- lib/pleroma/web/common_api/common_api.ex | 6 ++++-- test/web/activity_pub/transmogrifier_test.exs | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index a040a6ce2..b02c47059 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -217,14 +217,16 @@ def listen(user, %{"title" => _} = data) do {to, cc} <- get_to_and_cc(user, [], nil, visibility, nil), listen_data <- Map.take(data, ["album", "artist", "title", "length"]) - |> Map.put("type", "Audio"), + |> Map.put("type", "Audio") + |> Map.put("to", to) + |> Map.put("cc", cc), {:ok, activity} <- ActivityPub.listen(%{ actor: user, to: to, object: listen_data, context: Utils.generate_context_id(), - additional: %{cc: cc} + additional: %{"cc" => cc} }) do {:ok, activity} end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index f77311b3c..2c6357fe6 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1226,6 +1226,12 @@ test "it can handle Listen activities" do {:ok, modified} = Transmogrifier.prepare_outgoing(listen_activity.data) assert modified["type"] == "Listen" + + user = insert(:user) + + {:ok, activity} = CommonAPI.listen(user, %{"title" => "lain radio episode 1"}) + + {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) end end