common api: make sure the generated IR is actually federatable

This commit is contained in:
Ariadne Conill 2019-09-28 12:12:35 +00:00
parent e7309d3b60
commit 71eff09e56
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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