Fix Relay

This commit is contained in:
Egor Kislitsyn 2019-10-21 14:19:31 +07:00
parent 4ea1a61b00
commit c6fba62666
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
2 changed files with 11 additions and 12 deletions

View file

@ -53,9 +53,10 @@ def publish(_), do: {:error, "Not implemented"}
@spec list() :: {:ok, [String.t()]} | {:error, any()}
def list do
with %User{following: following} = _user <- get_actor() do
with %User{} = user <- get_actor() do
list =
following
user
|> User.following()
|> Enum.map(fn entry -> URI.parse(entry).host end)
|> Enum.uniq()

View file

@ -2572,22 +2572,20 @@ test "POST /relay", %{admin: admin} do
end
test "GET /relay", %{admin: admin} do
Pleroma.Web.ActivityPub.Relay.get_actor()
|> Ecto.Changeset.change(
following: [
"http://test-app.com/user/test1",
"http://test-app.com/user/test1",
"http://test-app-42.com/user/test1"
]
)
|> Pleroma.User.update_and_set_cache()
relay_user = Pleroma.Web.ActivityPub.Relay.get_actor()
["http://mastodon.example.org/users/admin", "https://mstdn.io/users/mayuutann"]
|> Enum.each(fn ap_id ->
{:ok, user} = User.get_or_fetch_by_ap_id(ap_id)
User.follow(relay_user, user)
end)
conn =
build_conn()
|> assign(:user, admin)
|> get("/api/pleroma/admin/relay")
assert json_response(conn, 200)["relays"] -- ["test-app.com", "test-app-42.com"] == []
assert json_response(conn, 200)["relays"] -- ["mastodon.example.org", "mstdn.io"] == []
end
test "DELETE /relay", %{admin: admin} do