logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 0495a07dc77d81abf46cbe166ae3fec14f705809
parent be611b143bf2840c039aaf63dbf1a73d9f9daf7b
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date:   Mon, 19 Oct 2020 04:26:35 +0000

Merge branch '2239-mute-fixes' into 'develop'

ActivityPub: Show own replies to muted users.

Closes #2239

See merge request pleroma/pleroma!3084

Diffstat:

Mlib/pleroma/web/activity_pub/activity_pub.ex9++++++++-
Mtest/pleroma/web/activity_pub/activity_pub_test.exs16++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -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 diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -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)