replies filtering for blocked domains
This commit is contained in:
parent
7e6ec778d9
commit
19f468c5bc
5 changed files with 15 additions and 95 deletions
|
|
@ -932,37 +932,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
query =
|
||||
if has_named_binding?(query, :object), do: query, else: Activity.with_joined_object(query)
|
||||
|
||||
# TODO: update after benchmarks
|
||||
query =
|
||||
case opts[:method] do
|
||||
:fun ->
|
||||
from(a in query,
|
||||
where:
|
||||
fragment(
|
||||
"recipients_contain_blocked_domains(?, ?) = false",
|
||||
a.recipients,
|
||||
^domain_blocks
|
||||
)
|
||||
)
|
||||
|
||||
:unnest ->
|
||||
from(a in query,
|
||||
where:
|
||||
fragment(
|
||||
"NOT ? && (SELECT ARRAY(SELECT split_part(UNNEST(?), '/', 3)))",
|
||||
^domain_blocks,
|
||||
a.recipients
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
query
|
||||
end
|
||||
|
||||
from(
|
||||
[activity, object: o] in query,
|
||||
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
|
||||
where: fragment("not (? && ?)", activity.recipients, ^blocked_ap_ids),
|
||||
where:
|
||||
fragment(
|
||||
"recipients_contain_blocked_domains(?, ?) = false",
|
||||
activity.recipients,
|
||||
^domain_blocks
|
||||
),
|
||||
where:
|
||||
fragment(
|
||||
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
||||
|
|
|
|||
|
|
@ -62,13 +62,6 @@ defmodule Pleroma.Web.ApiSpec.TimelineOperation do
|
|||
only_media_param(),
|
||||
with_muted_param(),
|
||||
exclude_visibilities_param(),
|
||||
# TODO: remove after benchmarks
|
||||
Operation.parameter(
|
||||
:method,
|
||||
:query,
|
||||
%Schema{type: :string},
|
||||
"Temp parameter"
|
||||
),
|
||||
reply_visibility_param() | pagination_params()
|
||||
],
|
||||
operationId: "TimelineController.public",
|
||||
|
|
|
|||
|
|
@ -109,23 +109,14 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
if restrict? and is_nil(user) do
|
||||
render_error(conn, :unauthorized, "authorization required for timeline view")
|
||||
else
|
||||
# TODO: return back after benchmarks
|
||||
params =
|
||||
activities =
|
||||
params
|
||||
|> Map.put("type", ["Create", "Announce"])
|
||||
|> Map.put("local_only", local_only)
|
||||
|> Map.put("blocking_user", user)
|
||||
|> Map.put("muting_user", user)
|
||||
|> Map.put("reply_filtering_user", user)
|
||||
|
||||
params =
|
||||
if params["method"] do
|
||||
Map.put(params, :method, String.to_existing_atom(params["method"]))
|
||||
else
|
||||
params
|
||||
end
|
||||
|
||||
activities = ActivityPub.fetch_public_activities(params)
|
||||
|> ActivityPub.fetch_public_activities()
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities, %{"local" => local_only})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue