aboutsummaryrefslogtreecommitdiff
path: root/lib/mix/tasks/pleroma/relay.ex
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2019-08-03 23:17:17 +0000
committerAriadne Conill <ariadne@dereferenced.org>2019-08-03 23:17:17 +0000
commitcef3af5536c16ff357fe2e0ed8c560aff16c62de (patch)
tree5cede31f6fff411230ba0676fbcebfca771758f5 /lib/mix/tasks/pleroma/relay.ex
parentb1fb5b93aeea5ae95c9d4cfc3ded8e330f2b0a66 (diff)
downloadpleroma-cef3af5536c16ff357fe2e0ed8c560aff16c62de.tar.gz
tasks: relay: add list task
Diffstat (limited to 'lib/mix/tasks/pleroma/relay.ex')
-rw-r--r--lib/mix/tasks/pleroma/relay.ex20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/relay.ex b/lib/mix/tasks/pleroma/relay.ex
index 83ed0ed02..c7324fff6 100644
--- a/lib/mix/tasks/pleroma/relay.ex
+++ b/lib/mix/tasks/pleroma/relay.ex
@@ -5,6 +5,7 @@
defmodule Mix.Tasks.Pleroma.Relay do
use Mix.Task
import Mix.Pleroma
+ alias Pleroma.User
alias Pleroma.Web.ActivityPub.Relay
@shortdoc "Manages remote relays"
@@ -22,6 +23,10 @@ defmodule Mix.Tasks.Pleroma.Relay do
``mix pleroma.relay unfollow <relay_url>``
Example: ``mix pleroma.relay unfollow https://example.org/relay``
+
+ ## List relay subscriptions
+
+ ``mix pleroma.relay list``
"""
def run(["follow", target]) do
start_pleroma()
@@ -44,4 +49,19 @@ defmodule Mix.Tasks.Pleroma.Relay do
{:error, e} -> shell_error("Error while following #{target}: #{inspect(e)}")
end
end
+
+ def run(["list"]) do
+ start_pleroma()
+
+ with %User{} = user <- Relay.get_actor() do
+ user.following
+ |> Enum.each(fn entry ->
+ URI.parse(entry)
+ |> Map.get(:host)
+ |> shell_info()
+ end)
+ else
+ e -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
+ end
+ end
end