exclude replies on blocked domains
This commit is contained in:
parent
fa37bfff99
commit
7e6ec778d9
9 changed files with 469 additions and 175 deletions
|
|
@ -932,6 +932,33 @@ 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),
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@ 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,14 +109,23 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
if restrict? and is_nil(user) do
|
||||
render_error(conn, :unauthorized, "authorization required for timeline view")
|
||||
else
|
||||
activities =
|
||||
# TODO: return back after benchmarks
|
||||
params =
|
||||
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)
|
||||
|> ActivityPub.fetch_public_activities()
|
||||
|
||||
params =
|
||||
if params["method"] do
|
||||
Map.put(params, :method, String.to_existing_atom(params["method"]))
|
||||
else
|
||||
params
|
||||
end
|
||||
|
||||
activities = ActivityPub.fetch_public_activities(params)
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities, %{"local" => local_only})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue