diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-06-18 03:18:39 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-06-18 03:21:32 +0000 |
commit | 4f589998ee2500504de1fcd3c1b5c00a12f6253d (patch) | |
tree | 2c3680a71b5e31bf6d39f8bed71783710f3a28e0 /lib | |
parent | 25946f772d1c1d3ff8a4d2c70824654a9c22fc23 (diff) | |
download | pleroma-4f589998ee2500504de1fcd3c1b5c00a12f6253d.tar.gz |
activitypub: support filtering activities by whether or not they are a reply (closes #109)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 267427a23..567ee3115 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -430,6 +430,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do defp restrict_media(query, _), do: query + defp restrict_replies(query, %{"exclude_replies" => val}) when val == "true" or val == "1" do + from( + activity in query, + where: fragment("?->'object'->>'inReplyTo' is null", activity.data) + ) + end + + defp restrict_replies(query, _), do: query + # Only search through last 100_000 activities by default defp restrict_recent(query, %{"whole_db" => true}), do: query @@ -487,6 +496,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> restrict_blocked(opts) |> restrict_media(opts) |> restrict_visibility(opts) + |> restrict_replies(opts) end def fetch_activities(recipients, opts \\ %{}) do |