mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Merge branch 'kaniini/pleroma-bugfix/unlisted-statuses' into develop
This commit is contained in:
commit
7e9f14bf3c
2 changed files with 23 additions and 1 deletions
|
@ -211,11 +211,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest 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