Commit facfd03b authored by Rin Toshaka's avatar Rin Toshaka
Browse files

Move relay tasks to relay.ex

parent e8ba579e
defmodule Mix.Tasks.RelayFollow do
defmodule Mix.Tasks.Pleroma.Relay do
use Mix.Task
require Logger
alias Pleroma.Web.ActivityPub.Relay
@shortdoc "Follows a remote relay"
@shortdoc "Manages remote relays"
@moduledoc """
Follows a remote relay
Manages remote relays
Usage: ``mix relay_follow <relay_url>``
## Follow a remote relay
Example: ``mix relay_follow https://example.org/relay``
``mix pleroma.relay unfollow <relay_url>``
Example: ``mix pleroma.relay follow https://example.org/relay``
## Unfollow a remote relay
``mix pleroma.relay unfollow <relay_url>``
Example: ``mix pleroma.relay unfollow https://example.org/relay``
"""
def run([target]) do
def run(["follow", target]) do
Mix.Task.run("app.start")
with {:ok, activity} <- Relay.follow(target) do
# put this task to sleep to allow the genserver to push out the messages
:timer.sleep(500)
else
{:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
end
end
def run(["unfollow", target]) do
Mix.Task.run("app.start")
with {:ok, activity} <- Relay.follow(target) do
......
defmodule Mix.Tasks.RelayUnfollow do
use Mix.Task
require Logger
alias Pleroma.Web.ActivityPub.Relay
@moduledoc """
Unfollows a remote relay
Usage: ``mix relay_follow <relay_url>``
Example: ``mix relay_follow https://example.org/relay``
"""
def run([target]) do
Mix.Task.run("app.start")
with {:ok, activity} <- Relay.follow(target) do
# put this task to sleep to allow the genserver to push out the messages
:timer.sleep(500)
else
{:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment