diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-11-10 15:31:37 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-11-17 22:12:13 +0100 |
commit | 12ccf0c4f835cee1e942e13482322b0d9a5e7c2d (patch) | |
tree | dbb34fbaabcc0e9fcc8c6d42e83b32ef6867118a /lib | |
parent | 4634d99d0d43c0a13fdca6ebc722c400facafa3d (diff) | |
download | pleroma-12ccf0c4f835cee1e942e13482322b0d9a5e7c2d.tar.gz |
Change Relay from `status` to `{status, message}`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mix/tasks/relay_follow.ex | 6 | ||||
-rw-r--r-- | lib/mix/tasks/relay_unfollow.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/relay.ex | 8 | ||||
-rw-r--r-- | lib/pleroma/web/admin_api/admin_api_controller.ex | 4 |
4 files changed, 14 insertions, 10 deletions
diff --git a/lib/mix/tasks/relay_follow.ex b/lib/mix/tasks/relay_follow.ex index 39cecb71b..bec63af7c 100644 --- a/lib/mix/tasks/relay_follow.ex +++ b/lib/mix/tasks/relay_follow.ex @@ -14,11 +14,13 @@ defmodule Mix.Tasks.RelayFollow do def run([target]) do 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 :timer.sleep(500) else - e -> Mix.puts("Error: #{inspect(e)}") + Mix.puts("Error: #{inspect(message)}") end end end diff --git a/lib/mix/tasks/relay_unfollow.ex b/lib/mix/tasks/relay_unfollow.ex index 5f12bd9ea..df719af2b 100644 --- a/lib/mix/tasks/relay_unfollow.ex +++ b/lib/mix/tasks/relay_unfollow.ex @@ -13,11 +13,13 @@ defmodule Mix.Tasks.RelayUnfollow do def run([target]) do 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 :timer.sleep(500) else - e -> Mix.puts("Error: #{inspect(e)}") + Mix.puts("Error: #{inspect(message)}") end end end diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index 107c57866..fcdc6b1c0 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -12,11 +12,11 @@ defmodule Pleroma.Web.ActivityPub.Relay do %User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance), {:ok, activity} <- ActivityPub.follow(local_user, target_user) do Logger.info("relay: followed instance: #{target_instance}; id=#{activity.data["id"]}") - :ok + {:ok, activity} else e -> Logger.error("error: #{inspect(e)}") - :error + {:error, e} end end @@ -25,11 +25,11 @@ defmodule Pleroma.Web.ActivityPub.Relay do %User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance), {:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}") - :ok + {:ok, activity} else e -> Logger.error("error: #{inspect(e)}") - :error + {:error, e} end end diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 5f6c565ae..39e85036e 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -102,7 +102,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do end def relay_follow(conn, %{"relay_url" => target}) do - status = Relay.follow(target) + {status, message} = Relay.follow(target) if status == :ok do conn @@ -115,7 +115,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do end def relay_unfollow(conn, %{"relay_url" => target}) do - status = Relay.unfollow(target) + {status, message} = Relay.unfollow(target) if status == :ok do conn |