Send salmons and websub in background tasks.

This commit is contained in:
Roger Braun 2017-05-05 20:38:10 +02:00
parent 7752f103f6
commit 04f6ece99e
2 changed files with 10 additions and 6 deletions

View file

@ -150,9 +150,11 @@ def publish(%{info: %{"keys" => keys}} = user, activity, poster) do
remote_users(activity) remote_users(activity)
|> Enum.each(fn(remote_user) -> |> Enum.each(fn(remote_user) ->
Task.start(fn ->
Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end) Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end)
send_to_user(remote_user, feed, poster) send_to_user(remote_user, feed, poster)
end) end)
end)
end end
end end

View file

@ -51,11 +51,13 @@ def publish(topic, user, activity) do
signature = sign(sub.secret || "", response) signature = sign(sub.secret || "", response)
Logger.debug(fn -> "Pushing to #{sub.callback}" end) Logger.debug(fn -> "Pushing to #{sub.callback}" end)
Task.start(fn ->
@httpoison.post(sub.callback, response, [ @httpoison.post(sub.callback, response, [
{"Content-Type", "application/atom+xml"}, {"Content-Type", "application/atom+xml"},
{"X-Hub-Signature", "sha1=#{signature}"} {"X-Hub-Signature", "sha1=#{signature}"}
]) ])
end) end)
end)
end end
def sign(secret, doc) do def sign(secret, doc) do