Merge branch 'parallel588/pleroma-support/compile_warnings' into 'develop'
[akkoma] / lib / mix / tasks / pleroma / relay.ex
1 defmodule Mix.Tasks.Pleroma.Relay do
2 use Mix.Task
3 alias Pleroma.Web.ActivityPub.Relay
4 alias Mix.Tasks.Pleroma.Common
5
6 @shortdoc "Manages remote relays"
7 @moduledoc """
8 Manages remote relays
9
10 ## Follow a remote relay
11
12 ``mix pleroma.relay follow <relay_url>``
13
14 Example: ``mix pleroma.relay follow https://example.org/relay``
15
16 ## Unfollow a remote relay
17
18 ``mix pleroma.relay unfollow <relay_url>``
19
20 Example: ``mix pleroma.relay unfollow https://example.org/relay``
21 """
22 def run(["follow", target]) do
23 Common.start_pleroma()
24
25 with {:ok, _activity} <- Relay.follow(target) do
26 # put this task to sleep to allow the genserver to push out the messages
27 :timer.sleep(500)
28 else
29 {:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
30 end
31 end
32
33 def run(["unfollow", target]) do
34 Common.start_pleroma()
35
36 with {:ok, _activity} <- Relay.unfollow(target) do
37 # put this task to sleep to allow the genserver to push out the messages
38 :timer.sleep(500)
39 else
40 {:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
41 end
42 end
43 end