|> :xmerl.export_simple(:xmerl_xml)
|> to_string
- signature = sign(sub.secret || "", response)
- Logger.debug(fn -> "Pushing to #{sub.callback}" end)
-
- Task.start(fn ->
- with {:ok, %{status_code: code}} <- @httpoison.post(sub.callback, response, [
- {"Content-Type", "application/atom+xml"},
- {"X-Hub-Signature", "sha1=#{signature}"}
- ]) do
- Logger.debug(fn -> "Pushed to #{sub.callback}, code #{code}" end)
- else e ->
- Logger.debug(fn -> "Couldn't push to #{sub.callback}, #{inspect(e)}" end)
- end
- end)
+ data = %{
+ xml: response,
+ topic: topic,
+ callback: sub.callback,
+ secret: sub.secret
+ }
+ Pleroma.Web.Federator.enqueue(:publish_single_websub, data)
end)
end
cut_off = NaiveDateTime.add(NaiveDateTime.utc_now, delta)
query = from sub in WebsubClientSubscription,
- where: sub.valid_until < ^cut_off and sub.state == "accepted"
+ where: sub.valid_until < ^cut_off
subs = Repo.all(query)
- Enum.map(subs, fn (sub) ->
- request_subscription(sub)
+ Enum.each(subs, fn (sub) ->
+ Pleroma.Web.Federator.enqueue(:request_subscription, sub)
end)
end
end