1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.Relay do
9 alias Pleroma.Web.ActivityPub.Relay
11 @shortdoc "Manages remote relays"
15 ## Follow a remote relay
17 ``mix pleroma.relay follow <relay_url>``
19 Example: ``mix pleroma.relay follow https://example.org/relay``
21 ## Unfollow a remote relay
23 ``mix pleroma.relay unfollow <relay_url>``
25 Example: ``mix pleroma.relay unfollow https://example.org/relay``
27 ## List relay subscriptions
29 ``mix pleroma.relay list``
31 def run(["follow", target]) do
34 with {:ok, _activity} <- Relay.follow(target) do
35 # put this task to sleep to allow the genserver to push out the messages
38 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
42 def run(["unfollow", target]) do
45 with {:ok, _activity} <- Relay.unfollow(target) do
46 # put this task to sleep to allow the genserver to push out the messages
49 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
56 with %User{following: following} = _user <- Relay.get_actor() do
58 |> Enum.map(fn entry -> URI.parse(entry).host end)
60 |> Enum.each(&shell_info(&1))
62 e -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")