1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.Relay do
8 alias Pleroma.Web.ActivityPub.Relay
10 @shortdoc "Manages remote relays"
11 @moduledoc File.read!("docs/administration/CLI_tasks/relay.md")
13 def run(["follow", target]) do
16 with {:ok, _activity} <- Relay.follow(target) do
17 # put this task to sleep to allow the genserver to push out the messages
20 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
24 def run(["unfollow", target | rest]) do
30 strict: [force: :boolean],
34 force = Keyword.get(options, :force, false)
36 with {:ok, _activity} <- Relay.unfollow(target, %{force: force}) do
37 # put this task to sleep to allow the genserver to push out the messages
40 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
47 with {:ok, list} <- Relay.list() do
48 Enum.each(list, &print_relay_url/1)
50 {:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
54 defp print_relay_url(%{followed_back: false} = relay) do
55 shell_info("#{relay.actor} - no Accept received (relay didn't follow back)")
58 defp print_relay_url(relay), do: shell_info(relay.actor)