diff options
author | kaniini <nenolod@gmail.com> | 2019-06-11 17:30:13 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2019-06-11 17:30:13 +0000 |
commit | 23db6774cf2a471feb4ae099d49c1f01d98e245c (patch) | |
tree | 8a380181e5d8b49627610b9216da187da276f01a /lib/pleroma/activity | |
parent | 3235923276650ac3a5b8a64c985f118d0f6e309e (diff) | |
parent | 6f29865d43f30303bc05bfb10aa28fe3ebef1bfd (diff) | |
download | pleroma-23db6774cf2a471feb4ae099d49c1f01d98e245c.tar.gz |
Merge branch 'improve-local-content-limit' into 'develop'
Add option to restrict all users to local content
See merge request pleroma/pleroma!1268
Diffstat (limited to 'lib/pleroma/activity')
-rw-r--r-- | lib/pleroma/activity/search.ex | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/pleroma/activity/search.ex b/lib/pleroma/activity/search.ex index 9ccedcd13..8cbb64cc4 100644 --- a/lib/pleroma/activity/search.ex +++ b/lib/pleroma/activity/search.ex @@ -56,18 +56,19 @@ defmodule Pleroma.Activity.Search do ) end - # users can search everything - defp maybe_restrict_local(q, %User{}), do: q + defp maybe_restrict_local(q, user) do + limit = Pleroma.Config.get([:instance, :limit_to_local_content], :unauthenticated) - # unauthenticated users can only search local activities - defp maybe_restrict_local(q, _) do - if Pleroma.Config.get([:instance, :limit_unauthenticated_to_local_content], true) do - where(q, local: true) - else - q + case {limit, user} do + {:all, _} -> restrict_local(q) + {:unauthenticated, %User{}} -> q + {:unauthenticated, _} -> restrict_local(q) + {false, _} -> q end end + defp restrict_local(q), do: where(q, local: true) + defp maybe_fetch(activities, user, search_query) do with true <- Regex.match?(~r/https?:/, search_query), {:ok, object} <- Fetcher.fetch_object_from_id(search_query), |