Merge branch 'relay-list-change' into 'develop'
authorfeld <feld@feld.me>
Wed, 11 Mar 2020 15:10:09 +0000 (15:10 +0000)
committerfeld <feld@feld.me>
Wed, 11 Mar 2020 15:10:09 +0000 (15:10 +0000)
Relay list shows hosts without accepted follow

See merge request pleroma/pleroma!2240

1  2 
lib/mix/tasks/pleroma/relay.ex
test/tasks/relay_test.exs
test/web/activity_pub/activity_pub_controller_test.exs

index c6ca888d4c65e1ab1afff5ae776b368bdeec2fe4,b0fadeae9b8bdd752683b4e5a39a2c16dc85cc7a..c3312507e93786dcbebe0194177d84f9fc112c38
@@@ -1,5 -1,5 +1,5 @@@
  # Pleroma: A lightweight social networking server
 -# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  # SPDX-License-Identifier: AGPL-3.0-only
  
  defmodule Mix.Tasks.Pleroma.Relay do
@@@ -35,7 -35,7 +35,7 @@@
    def run(["list"]) do
      start_pleroma()
  
-     with {:ok, list} <- Relay.list() do
+     with {:ok, list} <- Relay.list(true) do
        list |> Enum.each(&shell_info(&1))
      else
        {:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
index 08855f2459147220345106a0145164096b6746d1,43565b7c7403f2efef1aa9d6120d7d3a8f223d4e..d3d88467d2cf5e5e15de6d1dee307353694bdbe3
@@@ -1,5 -1,5 +1,5 @@@
  # Pleroma: A lightweight social networking server
 -# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  # SPDX-License-Identifier: AGPL-3.0-only
  
  defmodule Mix.Tasks.Pleroma.RelayTest do
@@@ -38,6 -38,9 +38,9 @@@
        assert activity.data["type"] == "Follow"
        assert activity.data["actor"] == local_user.ap_id
        assert activity.data["object"] == target_user.ap_id
+       :ok = Mix.Tasks.Pleroma.Relay.run(["list"])
+       assert_receive {:mix_shell, :info, ["mastodon.example.org (no Accept received)"]}
      end
    end
  
index 9151034da1bb229dc4abeb39e860a79e50dd1794,0c80e2434c686b765957bbdbf53ff0f7e8967542..b2352538a3f41acde656604d509f9675cd586a17
@@@ -1,5 -1,5 +1,5 @@@
  # Pleroma: A lightweight social networking server
 -# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  # SPDX-License-Identifier: AGPL-3.0-only
  
  defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
        assert "ok" == json_response(conn, 200)
        assert Instances.reachable?(sender_url)
      end
+     test "accept follow activity", %{conn: conn} do
+       Pleroma.Config.put([:instance, :federating], true)
+       relay = Relay.get_actor()
+       assert {:ok, %Activity{} = activity} = Relay.follow("https://relay.mastodon.host/actor")
+       followed_relay = Pleroma.User.get_by_ap_id("https://relay.mastodon.host/actor")
+       relay = refresh_record(relay)
+       accept =
+         File.read!("test/fixtures/relay/accept-follow.json")
+         |> String.replace("{{ap_id}}", relay.ap_id)
+         |> String.replace("{{activity_id}}", activity.data["id"])
+       assert "ok" ==
+                conn
+                |> assign(:valid_signature, true)
+                |> put_req_header("content-type", "application/activity+json")
+                |> post("/inbox", accept)
+                |> json_response(200)
+       ObanHelpers.perform(all_enqueued(worker: ReceiverWorker))
+       assert Pleroma.FollowingRelationship.following?(
+                relay,
+                followed_relay
+              )
+       Mix.shell(Mix.Shell.Process)
+       on_exit(fn ->
+         Mix.shell(Mix.Shell.IO)
+       end)
+       :ok = Mix.Tasks.Pleroma.Relay.run(["list"])
+       assert_receive {:mix_shell, :info, ["relay.mastodon.host"]}
+     end
    end
  
    describe "/users/:nickname/inbox" do