forked from AkkomaGang/akkoma
lib/mix/tasks/relay*: Use a with block
This commit is contained in:
parent
12ccf0c4f8
commit
44b6200103
2 changed files with 4 additions and 8 deletions
|
@ -14,13 +14,11 @@ defmodule Mix.Tasks.RelayFollow do
|
||||||
def run([target]) do
|
def run([target]) do
|
||||||
Mix.Task.run("app.start")
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
{status, message} = Relay.follow(target)
|
with {:ok, activity} <- Relay.follow(target) do
|
||||||
|
|
||||||
if :ok == status do
|
|
||||||
# put this task to sleep to allow the genserver to push out the messages
|
# put this task to sleep to allow the genserver to push out the messages
|
||||||
:timer.sleep(500)
|
:timer.sleep(500)
|
||||||
else
|
else
|
||||||
Mix.puts("Error: #{inspect(message)}")
|
{:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,13 +13,11 @@ defmodule Mix.Tasks.RelayUnfollow do
|
||||||
def run([target]) do
|
def run([target]) do
|
||||||
Mix.Task.run("app.start")
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
{status, message} = Relay.unfollow(target)
|
with {:ok, activity} <- Relay.follow(target) do
|
||||||
|
|
||||||
if :ok == status do
|
|
||||||
# put this task to sleep to allow the genserver to push out the messages
|
# put this task to sleep to allow the genserver to push out the messages
|
||||||
:timer.sleep(500)
|
:timer.sleep(500)
|
||||||
else
|
else
|
||||||
Mix.puts("Error: #{inspect(message)}")
|
{:error, e} -> Mix.shell().error("Error while following #{target}: #{inspect(e)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue