From c4235f96bde49def1fb6927ba79a49a0f75cd60a Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 27 Feb 2019 16:37:42 +0100 Subject: [PATCH] Add `with_muted` param. --- docs/Differences-in-MastodonAPI-Responses.md | 4 ++++ lib/pleroma/web/activity_pub/activity_pub.ex | 2 ++ test/web/activity_pub/activity_pub_test.exs | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/docs/Differences-in-MastodonAPI-Responses.md b/docs/Differences-in-MastodonAPI-Responses.md index f6a5b6461..3026e1173 100644 --- a/docs/Differences-in-MastodonAPI-Responses.md +++ b/docs/Differences-in-MastodonAPI-Responses.md @@ -9,3 +9,7 @@ Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However just like Mas ## Attachment cap Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting. + +## Timelines + +Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users. diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index cc255cc9e..52404c7e5 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -602,6 +602,8 @@ defp restrict_reblogs(query, %{"exclude_reblogs" => val}) when val == "true" or defp restrict_reblogs(query, _), do: query + defp restrict_muted(query, %{"with_muted" => val}) when val in [true, "true", "1"], do: query + defp restrict_muted(query, %{"muting_user" => %User{info: info}}) do mutes = info.mutes diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 11262c523..ac3a565de 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -291,6 +291,13 @@ test "doesn't return muted activities" do assert Enum.member?(activities, activity_three) refute Enum.member?(activities, activity_one) + # Calling with 'with_muted' will deliver muted activities, too. + activities = ActivityPub.fetch_activities([], %{"muting_user" => user, "with_muted" => true}) + + assert Enum.member?(activities, activity_two) + assert Enum.member?(activities, activity_three) + assert Enum.member?(activities, activity_one) + {:ok, user} = User.unmute(user, %User{ap_id: activity_one.data["actor"]}) activities = ActivityPub.fetch_activities([], %{"muting_user" => user})