ActivityPub: Show own replies to muted users.
authorlain <lain@soykaf.club>
Thu, 15 Oct 2020 10:28:25 +0000 (12:28 +0200)
committerlain <lain@soykaf.club>
Thu, 15 Oct 2020 10:28:25 +0000 (12:28 +0200)
Aligns mute with block behavior.

lib/pleroma/web/activity_pub/activity_pub.ex
test/pleroma/web/activity_pub/activity_pub_test.exs

index 8022f0402be73bcdb4f87ba5a1cffe9bcb4ddd90..ff7b9e7783aec9a6086bfbdfe5ec2b535bbcbe40 100644 (file)
@@ -827,7 +827,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     query =
       from([activity] in query,
         where: fragment("not (? = ANY(?))", activity.actor, ^mutes),
-        where: fragment("not (?->'to' \\?| ?)", activity.data, ^mutes)
+        where:
+          fragment(
+            "not (?->'to' \\?| ?) or ? = ?",
+            activity.data,
+            ^mutes,
+            activity.actor,
+            ^user.ap_id
+          )
       )
 
     unless opts[:skip_preload] do
index 1a8a844ca89466202cf92e069634828096a90b95..e6b6086e674aa3deb1cc6781bc795f13dd3110ec 100644 (file)
@@ -752,6 +752,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
     refute repeat_activity in activities
   end
 
+  test "returns your own posts regardless of mute" do
+    user = insert(:user)
+    muted = insert(:user)
+
+    {:ok, muted_post} = CommonAPI.post(muted, %{status: "Im stupid"})
+
+    {:ok, reply} =
+      CommonAPI.post(user, %{status: "I'm muting you", in_reply_to_status_id: muted_post.id})
+
+    {:ok, _} = User.mute(user, muted)
+
+    [activity] = ActivityPub.fetch_activities([], %{muting_user: user, skip_preload: true})
+
+    assert activity.id == reply.id
+  end
+
   test "doesn't return muted activities" do
     activity_one = insert(:note_activity)
     activity_two = insert(:note_activity)