forked from AkkomaGang/akkoma
ActivityPub core: fix handling of unlisted statuses by leveraging a similar strategy as for blocks
This commit is contained in:
parent
a7a40bb8f1
commit
a3d1d4894f
1 changed files with 8 additions and 1 deletions
|
@ -212,11 +212,11 @@ def fetch_activities_for_context(context, opts \\ %{}) do
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Make this work properly with unlisted.
|
|
||||||
def fetch_public_activities(opts \\ %{}) do
|
def fetch_public_activities(opts \\ %{}) do
|
||||||
q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
|
q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
|
||||||
|
|
||||||
q
|
q
|
||||||
|
|> restrict_unlisted()
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.reverse()
|
|> Enum.reverse()
|
||||||
end
|
end
|
||||||
|
@ -321,6 +321,13 @@ defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
|
||||||
|
|
||||||
defp restrict_blocked(query, _), do: query
|
defp restrict_blocked(query, _), do: query
|
||||||
|
|
||||||
|
defp restrict_unlisted(query) do
|
||||||
|
from(
|
||||||
|
activity in query,
|
||||||
|
where: fragment("not (?->'cc' \\?| ?)", activity.data, ^["https://www.w3.org/ns/activitystreams#Public"])
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_activities_query(recipients, opts \\ %{}) do
|
def fetch_activities_query(recipients, opts \\ %{}) do
|
||||||
base_query =
|
base_query =
|
||||||
from(
|
from(
|
||||||
|
|
Loading…
Reference in a new issue