diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-06-19 05:15:11 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-06-19 05:15:11 +0000 |
commit | db0731b6ac077c341f6e6779af2c2d5a94d3d14a (patch) | |
tree | 2fc2c5d1bb7bf04aec2d864900b0b08f5d7df330 | |
parent | de80363518d7f5118cef6528e64fd12a574707a6 (diff) | |
parent | 4f589998ee2500504de1fcd3c1b5c00a12f6253d (diff) | |
download | pleroma-db0731b6ac077c341f6e6779af2c2d5a94d3d14a.tar.gz pleroma-db0731b6ac077c341f6e6779af2c2d5a94d3d14a.zip |
Merge branch 'feature/exclude-replies-filter' into 'develop'
activitypub: support filtering activities by whether or not they are a reply (closes #109)
Closes #109
See merge request pleroma/pleroma!226
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 10 | ||||
-rw-r--r-- | priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs | 8 |
2 files changed, 18 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 diff --git a/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs b/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs new file mode 100644 index 000000000..1fee6fd7a --- /dev/null +++ b/priv/repo/migrations/20180617221540_create_activities_in_reply_to_index.exs @@ -0,0 +1,8 @@ +defmodule Pleroma.Repo.Migrations.CreateActivitiesInReplyToIndex do + use Ecto.Migration + @disable_ddl_transaction true + + def change do + create index(:activities, ["(data->'object'->>'inReplyTo')"], concurrently: true, name: :activities_in_reply_to) + end +end |