diff options
author | faried nawaz <faried@gmail.com> | 2022-12-07 22:37:50 +0500 |
---|---|---|
committer | faried nawaz <faried@gmail.com> | 2023-07-28 18:45:59 +0500 |
commit | dc4de79d43ba941d8aa16f7c14887faae9f65e9f (patch) | |
tree | 23a1137c6e0affe735f87a0d89a52e72f9f8d121 /lib | |
parent | 93ad16cca0a5b6acc1308027f798e347f44de4f8 (diff) | |
download | pleroma-dc4de79d43ba941d8aa16f7c14887faae9f65e9f.tar.gz pleroma-dc4de79d43ba941d8aa16f7c14887faae9f65e9f.zip |
status context: perform visibility check on activities around a status
issue #2927
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 23 |
1 files changed, 23 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..f1a12d22d 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,28 @@ 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 -> + # is there a better way to handle this? + from(activity in query, where: 1 == 0) + + 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 |