Change Relay from status
to {status, message}
This commit is contained in:
parent
4634d99d0d
commit
12ccf0c4f8
@ -14,11 +14,13 @@ defmodule Mix.Tasks.RelayFollow do
|
|||||||
def run([target]) do
|
def run([target]) do
|
||||||
Mix.Task.run("app.start")
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
with :ok <- Relay.follow(target) do
|
{status, message} = Relay.follow(target)
|
||||||
|
|
||||||
|
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
|
||||||
e -> Mix.puts("Error: #{inspect(e)}")
|
Mix.puts("Error: #{inspect(message)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,11 +13,13 @@ defmodule Mix.Tasks.RelayUnfollow do
|
|||||||
def run([target]) do
|
def run([target]) do
|
||||||
Mix.Task.run("app.start")
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
with :ok <- Relay.unfollow(target) do
|
{status, message} = Relay.unfollow(target)
|
||||||
|
|
||||||
|
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
|
||||||
e -> Mix.puts("Error: #{inspect(e)}")
|
Mix.puts("Error: #{inspect(message)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,11 +12,11 @@ defmodule Pleroma.Web.ActivityPub.Relay do
|
|||||||
%User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
|
%User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
|
||||||
{:ok, activity} <- ActivityPub.follow(local_user, target_user) do
|
{:ok, activity} <- ActivityPub.follow(local_user, target_user) do
|
||||||
Logger.info("relay: followed instance: #{target_instance}; id=#{activity.data["id"]}")
|
Logger.info("relay: followed instance: #{target_instance}; id=#{activity.data["id"]}")
|
||||||
:ok
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
e ->
|
e ->
|
||||||
Logger.error("error: #{inspect(e)}")
|
Logger.error("error: #{inspect(e)}")
|
||||||
:error
|
{:error, e}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ defmodule Pleroma.Web.ActivityPub.Relay do
|
|||||||
%User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
|
%User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
|
||||||
{:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do
|
{:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do
|
||||||
Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}")
|
Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}")
|
||||||
:ok
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
e ->
|
e ->
|
||||||
Logger.error("error: #{inspect(e)}")
|
Logger.error("error: #{inspect(e)}")
|
||||||
:error
|
{:error, e}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def relay_follow(conn, %{"relay_url" => target}) do
|
def relay_follow(conn, %{"relay_url" => target}) do
|
||||||
status = Relay.follow(target)
|
{status, message} = Relay.follow(target)
|
||||||
|
|
||||||
if status == :ok do
|
if status == :ok do
|
||||||
conn
|
conn
|
||||||
@ -115,7 +115,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def relay_unfollow(conn, %{"relay_url" => target}) do
|
def relay_unfollow(conn, %{"relay_url" => target}) do
|
||||||
status = Relay.unfollow(target)
|
{status, message} = Relay.unfollow(target)
|
||||||
|
|
||||||
if status == :ok do
|
if status == :ok do
|
||||||
conn
|
conn
|
||||||
|
Loading…
Reference in New Issue
Block a user