Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Mix.Tasks.Pleroma.Relay do
  5. use Mix.Task
  6. import Mix.Pleroma
  7. alias Pleroma.Web.ActivityPub.Relay
  8. @shortdoc "Manages remote relays"
  9. @moduledoc File.read!("docs/administration/CLI_tasks/relay.md")
  10. def run(["follow", target]) do
  11. start_pleroma()
  12. with {:ok, _activity} <- Relay.follow(target) do
  13. # put this task to sleep to allow the genserver to push out the messages
  14. :timer.sleep(500)
  15. else
  16. {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
  17. end
  18. end
  19. def run(["unfollow", target]) do
  20. start_pleroma()
  21. with {:ok, _activity} <- Relay.unfollow(target) do
  22. # put this task to sleep to allow the genserver to push out the messages
  23. :timer.sleep(500)
  24. else
  25. {:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
  26. end
  27. end
  28. def run(["list"]) do
  29. start_pleroma()
  30. with {:ok, list} <- Relay.list() do
  31. list |> Enum.each(&shell_info(&1))
  32. else
  33. {:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
  34. end
  35. end
  36. end