2020-10-30 15:16:01 +01:00
|
|
|
defmodule Mix.Tasks.Mobilizon.Relay.Accept do
|
|
|
|
@moduledoc """
|
|
|
|
Task to accept an instance follow request
|
|
|
|
"""
|
|
|
|
use Mix.Task
|
|
|
|
alias Mobilizon.Federation.ActivityPub.Relay
|
|
|
|
import Mix.Tasks.Mobilizon.Common
|
|
|
|
|
|
|
|
@shortdoc "Accept an instance follow request"
|
|
|
|
|
|
|
|
@impl Mix.Task
|
|
|
|
def run([target]) do
|
|
|
|
start_mobilizon()
|
|
|
|
|
|
|
|
case Relay.accept(target) do
|
2021-10-05 17:43:45 +02:00
|
|
|
{:ok, _activity, _follow} ->
|
2020-10-30 15:16:01 +01:00
|
|
|
# put this task to sleep to allow the genserver to push out the messages
|
|
|
|
:timer.sleep(500)
|
|
|
|
|
|
|
|
{:error, e} ->
|
|
|
|
IO.puts(:stderr, "Error while accept #{target} follow: #{inspect(e)}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(_) do
|
|
|
|
shell_error("mobilizon.relay.accept requires an instance hostname as arguments")
|
|
|
|
end
|
|
|
|
end
|