mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-18 10:59:17 +00:00
Merge branch 'kaniini/pleroma-bugfix/unlisted-statuses' into develop
This commit is contained in:
commit
7e9f14bf3c
|
@ -211,11 +211,11 @@ def fetch_activities_for_context(context, opts \\ %{}) do
|
|||
Repo.all(query)
|
||||
end
|
||||
|
||||
# TODO: Make this work properly with unlisted.
|
||||
def fetch_public_activities(opts \\ %{}) do
|
||||
q = fetch_activities_query(["https://www.w3.org/ns/activitystreams#Public"], opts)
|
||||
|
||||
q
|
||||
|> restrict_unlisted()
|
||||
|> Repo.all()
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
@ -322,6 +322,18 @@ defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
|
|||
|
||||
defp restrict_blocked(query, _), do: query
|
||||
|
||||
defp restrict_unlisted(query) do
|
||||
from(
|
||||
activity in query,
|
||||
where:
|
||||
fragment(
|
||||
"(?->'to' \\?| ?)",
|
||||
activity.data,
|
||||
^["https://www.w3.org/ns/activitystreams#Public"]
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def fetch_activities_query(recipients, opts \\ %{}) do
|
||||
base_query =
|
||||
from(
|
||||
|
|
|
@ -171,6 +171,16 @@ test "doesn't return blocked activities" do
|
|||
end
|
||||
|
||||
describe "public fetch activities" do
|
||||
test "doesn't retrieve unlisted activities" do
|
||||
user = insert(:user)
|
||||
{:ok, unlisted_activity} = CommonAPI.post(user, %{"status" => "yeah", "visibility" => "unlisted"})
|
||||
{:ok, listed_activity} = CommonAPI.post(user, %{"status" => "yeah"})
|
||||
|
||||
[activity] = ActivityPub.fetch_public_activities()
|
||||
|
||||
assert activity == listed_activity
|
||||
end
|
||||
|
||||
test "retrieves public activities" do
|
||||
_activities = ActivityPub.fetch_public_activities()
|
||||
|
||||
|
|
Loading…
Reference in a new issue