common api: make sure the generated IR is actually federatable
authorAriadne Conill <ariadne@dereferenced.org>
Sat, 28 Sep 2019 12:12:35 +0000 (12:12 +0000)
committerAriadne Conill <ariadne@dereferenced.org>
Mon, 30 Sep 2019 10:39:48 +0000 (10:39 +0000)
lib/pleroma/web/common_api/common_api.ex
test/web/activity_pub/transmogrifier_test.exs

index a040a6ce2bf68604d8da55a09a980b17273cce3d..b02c47059b27698a187332c3f88ae6e120642a15 100644 (file)
@@ -217,14 +217,16 @@ defmodule Pleroma.Web.CommonAPI 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
index f77311b3c3324d9fad491a23138a240e8b761874..2c6357fe6483b34ee037bdcc69b478d8669380a4 100644 (file)
@@ -1226,6 +1226,12 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest 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