Strip status data from Flag (when federating or closing/resolving report)
[akkoma] / lib / mix / tasks / pleroma / relay.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Mix.Tasks.Pleroma.Relay do
6 use Mix.Task
7 import Mix.Pleroma
8 alias Pleroma.User
9 alias Pleroma.Web.ActivityPub.Relay
10
11 @shortdoc "Manages remote relays"
12 @moduledoc File.read!("docs/administration/CLI_tasks/relay.md")
13
14 def run(["follow", target]) do
15 start_pleroma()
16
17 with {:ok, _activity} <- Relay.follow(target) do
18 # put this task to sleep to allow the genserver to push out the messages
19 :timer.sleep(500)
20 else
21 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
22 end
23 end
24
25 def run(["unfollow", target]) do
26 start_pleroma()
27
28 with {:ok, _activity} <- Relay.unfollow(target) do
29 # put this task to sleep to allow the genserver to push out the messages
30 :timer.sleep(500)
31 else
32 {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
33 end
34 end
35
36 def run(["list"]) do
37 start_pleroma()
38
39 with %User{following: following} = _user <- Relay.get_actor() do
40 following
41 |> Enum.map(fn entry -> URI.parse(entry).host end)
42 |> Enum.uniq()
43 |> Enum.each(&shell_info(&1))
44 else
45 e -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
46 end
47 end
48 end