From 04f6ece99ef15d0e0ced330e3945307499b7a715 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 5 May 2017 20:38:10 +0200 Subject: [PATCH] Send salmons and websub in background tasks. --- lib/pleroma/web/salmon/salmon.ex | 6 ++++-- lib/pleroma/web/websub/websub.ex | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index b95ad48ad..b4f81b4ed 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -150,8 +150,10 @@ def publish(%{info: %{"keys" => keys}} = user, activity, poster) do remote_users(activity) |> Enum.each(fn(remote_user) -> - Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end) - send_to_user(remote_user, feed, poster) + Task.start(fn -> + Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end) + send_to_user(remote_user, feed, poster) + end) end) end end diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex index 7bdb778ad..a5abc303c 100644 --- a/lib/pleroma/web/websub/websub.ex +++ b/lib/pleroma/web/websub/websub.ex @@ -51,10 +51,12 @@ def publish(topic, user, activity) do signature = sign(sub.secret || "", response) Logger.debug(fn -> "Pushing to #{sub.callback}" end) - @httpoison.post(sub.callback, response, [ - {"Content-Type", "application/atom+xml"}, - {"X-Hub-Signature", "sha1=#{signature}"} - ]) + Task.start(fn -> + @httpoison.post(sub.callback, response, [ + {"Content-Type", "application/atom+xml"}, + {"X-Hub-Signature", "sha1=#{signature}"} + ]) + end) end) end