2018-08-06 00:14:16 -07:00
|
|
|
defmodule Mix.Tasks.RelayFollow do
|
|
|
|
use Mix.Task
|
|
|
|
require Logger
|
|
|
|
alias Pleroma.Web.ActivityPub.Relay
|
|
|
|
|
|
|
|
@shortdoc "Follows a remote relay"
|
2018-11-08 06:28:50 -08:00
|
|
|
@moduledoc """
|
2018-11-08 06:21:09 -08:00
|
|
|
Follows a remote relay
|
|
|
|
|
|
|
|
Usage: ``mix relay_follow <relay_url>``
|
|
|
|
|
|
|
|
Example: ``mix relay_follow https://example.org/relay``
|
|
|
|
"""
|
2018-08-06 00:14:16 -07:00
|
|
|
def run([target]) do
|
|
|
|
Mix.Task.run("app.start")
|
|
|
|
|
2018-11-10 06:31:37 -08:00
|
|
|
{status, message} = Relay.follow(target)
|
|
|
|
|
|
|
|
if :ok == status do
|
2018-11-10 06:08:03 -08:00
|
|
|
# put this task to sleep to allow the genserver to push out the messages
|
|
|
|
:timer.sleep(500)
|
|
|
|
else
|
2018-11-10 06:31:37 -08:00
|
|
|
Mix.puts("Error: #{inspect(message)}")
|
2018-11-10 06:08:03 -08:00
|
|
|
end
|
2018-08-06 00:14:16 -07:00
|
|
|
end
|
|
|
|
end
|