Fix Relay
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 21 Oct 2019 07:19:31 +0000 (14:19 +0700)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 21 Oct 2019 07:47:07 +0000 (14:47 +0700)
lib/pleroma/web/activity_pub/relay.ex
test/web/admin_api/admin_api_controller_test.exs

index 03fc434a98119975fc01dc1b603fd1e29d1de739..830d1cde8a08ba09bc7f5a6d2e5c222279f8c0fe 100644 (file)
@@ -53,9 +53,10 @@ defmodule Pleroma.Web.ActivityPub.Relay do
 
   @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()
 
index 9da4940be5132a2a0c44d8eb2e235094e852d5d0..6dc0d4dca59561a68cc7bcbf47ca21a54268c0e5 100644 (file)
@@ -2572,22 +2572,20 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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