diff options
author | tusooa <tusooa@kazv.moe> | 2023-07-28 15:05:46 +0000 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2023-07-28 15:05:46 +0000 |
commit | b08cbe76f18c1e745511adf26ebdc3b675dd45ba (patch) | |
tree | 399234002b50c00e229e2c301b69d1f5504b5e79 /lib | |
parent | 93ad16cca0a5b6acc1308027f798e347f44de4f8 (diff) | |
parent | 11ce81d4af6b428fabb9d4c6f0098d786a21487b (diff) | |
download | pleroma-b08cbe76f18c1e745511adf26ebdc3b675dd45ba.tar.gz pleroma-b08cbe76f18c1e745511adf26ebdc3b675dd45ba.zip |
Merge branch 'fix/2927-disallow-unauthenticated-access' into 'develop'
/api/v1/statuses/:id/context: filter context activities using Visibility.visible_for_user?/2
See merge request pleroma/pleroma!3801
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index c93288b79..3979d418e 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -455,6 +455,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> maybe_preload_objects(opts) |> maybe_preload_bookmarks(opts) |> maybe_set_thread_muted_field(opts) + |> restrict_unauthenticated(opts[:user]) |> restrict_blocked(opts) |> restrict_blockers_visibility(opts) |> restrict_recipients(recipients, opts[:user]) @@ -1215,6 +1216,27 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do defp restrict_filtered(query, _), do: query + defp restrict_unauthenticated(query, nil) do + local = Config.restrict_unauthenticated_access?(:activities, :local) + remote = Config.restrict_unauthenticated_access?(:activities, :remote) + + cond do + local and remote -> + from(activity in query, where: false) + + local -> + from(activity in query, where: activity.local == false) + + remote -> + from(activity in query, where: activity.local == true) + + true -> + query + end + end + + defp restrict_unauthenticated(query, _), do: query + defp exclude_poll_votes(query, %{include_poll_votes: true}), do: query defp exclude_poll_votes(query, _) do |