mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-18 10:59:17 +00:00
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
This commit is contained in:
commit
db0731b6ac
|
@ -430,6 +430,15 @@ defp restrict_media(query, %{"only_media" => val}) when val == "true" or val ==
|
||||||
|
|
||||||
defp restrict_media(query, _), do: query
|
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
|
# Only search through last 100_000 activities by default
|
||||||
defp restrict_recent(query, %{"whole_db" => true}), do: query
|
defp restrict_recent(query, %{"whole_db" => true}), do: query
|
||||||
|
|
||||||
|
@ -487,6 +496,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do
|
||||||
|> restrict_blocked(opts)
|
|> restrict_blocked(opts)
|
||||||
|> restrict_media(opts)
|
|> restrict_media(opts)
|
||||||
|> restrict_visibility(opts)
|
|> restrict_visibility(opts)
|
||||||
|
|> restrict_replies(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_activities(recipients, opts \\ %{}) do
|
def fetch_activities(recipients, opts \\ %{}) do
|
||||||
|
|
|
@ -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
|
Loading…
Reference in a new issue