Streamer: Correctly handle reblog mutes
authorlain <lain@soykaf.club>
Tue, 28 Jan 2020 15:40:44 +0000 (16:40 +0100)
committerlain <lain@soykaf.club>
Tue, 28 Jan 2020 15:40:44 +0000 (16:40 +0100)
lib/pleroma/web/streamer/worker.ex
test/web/streamer/streamer_test.exs

index a1b445f2f131dfad9f9973aadfb40d9c6d15307e..5392c1ec36b1fb4aa7089bc81f39ee0e865ebaee 100644 (file)
@@ -138,7 +138,8 @@ defmodule Pleroma.Web.Streamer.Worker do
 
     with parent <- Object.normalize(item) || item,
          true <-
-           Enum.all?([blocked_ap_ids, muted_ap_ids, reblog_muted_ap_ids], &(item.actor not in &1)),
+           Enum.all?([blocked_ap_ids, muted_ap_ids], &(item.actor not in &1)),
+         true <- item.data["type"] != "Announce" || item.actor not in reblog_muted_ap_ids,
          true <- Enum.all?([blocked_ap_ids, muted_ap_ids], &(parent.data["actor"] not in &1)),
          true <- MapSet.disjoint?(recipients, recipient_blocks),
          %{host: item_host} <- URI.parse(item.actor),
index 7166d6f0ba3d70a22405160965d2ade8ef9e4e12..848158a4424e51d711701cfd50498df2cd895b78 100644 (file)
@@ -455,6 +455,34 @@ defmodule Pleroma.Web.StreamerTest do
     Task.await(task)
   end
 
+  test "it does send non-reblog notification for mtued" do
+    user1 = insert(:user)
+    user2 = insert(:user)
+    user3 = insert(:user)
+    CommonAPI.hide_reblogs(user1, user2)
+
+    task =
+      Task.async(fn ->
+        assert_receive {:text, _}, 1_000
+      end)
+
+    fake_socket = %StreamerSocket{
+      transport_pid: task.pid,
+      user: user1
+    }
+
+    {:ok, create_activity} = CommonAPI.post(user3, %{"status" => "I'm kawen"})
+    {:ok, favorite_activity, _} = CommonAPI.favorite(create_activity.id, user2)
+
+    topics = %{
+      "public" => [fake_socket]
+    }
+
+    Worker.push_to_socket(topics, "public", favorite_activity)
+
+    Task.await(task)
+  end
+
   test "it doesn't send posts from muted threads" do
     user = insert(:user)
     user2 = insert(:user)