From c311a5e50709ca04c3c7d5523198415114ce03a5 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 6 Sep 2022 19:55:52 +0100 Subject: [PATCH] update streamer tests --- lib/pleroma/web/streamer.ex | 7 +++++-- test/pleroma/web/streamer_test.exs | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 77ca14a97..c03e7fc30 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -292,12 +292,15 @@ defp push_to_socket(topic, %Activity{data: %{"type" => "Update"}} = item) do Pleroma.Activity.get_create_by_object_ap_id(item.object.data["id"]) |> Map.put(:object, item.object) - anon_render = StreamerView.render("status_update.json", create_activity) + anon_render = StreamerView.render("status_update.json", create_activity, topic) Registry.dispatch(@registry, topic, fn list -> Enum.each(list, fn {pid, auth?} -> if auth? do - send(pid, {:render_with_user, StreamerView, "status_update.json", create_activity}) + send( + pid, + {:render_with_user, StreamerView, "status_update.json", create_activity, topic} + ) else send(pid, {:text, anon_render}) end diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs index edbdb1bb5..8e2ab5016 100644 --- a/test/pleroma/web/streamer_test.exs +++ b/test/pleroma/web/streamer_test.exs @@ -394,7 +394,8 @@ test "it streams edits in the 'user' stream", %{user: user, token: oauth_token} {:ok, edited} = CommonAPI.update(sender, activity, %{status: "mew mew"}) create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"]) - assert_receive {:render_with_user, _, "status_update.json", ^create} + stream = "user:#{user.id}" + assert_receive {:render_with_user, _, "status_update.json", ^create, ^stream} refute Streamer.filtered_by_user?(user, edited) end @@ -405,7 +406,8 @@ test "it streams own edits in the 'user' stream", %{user: user, token: oauth_tok {:ok, edited} = CommonAPI.update(user, activity, %{status: "mew mew"}) create = Pleroma.Activity.get_create_by_object_ap_id_with_object(activity.object.data["id"]) - assert_receive {:render_with_user, _, "status_update.json", ^create} + stream = "user:#{user.id}" + assert_receive {:render_with_user, _, "status_update.json", ^create, ^stream} refute Streamer.filtered_by_user?(user, edited) end end