Send push notification into own task
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
d87261a6fb
commit
926dd01272
|
@ -25,7 +25,14 @@ defmodule Mobilizon.Service.Notifier.Push do
|
|||
options = Keyword.put_new(options, :locale, locale)
|
||||
|
||||
%Page{elements: subscriptions} = Users.list_user_push_subscriptions(user_id, 1, 100)
|
||||
Enum.each(subscriptions, &send_subscription(activity, convert_subscription(&1), options))
|
||||
|
||||
subscriptions
|
||||
|> Enum.map(&convert_subscription/1)
|
||||
|> Enum.map(fn subscription ->
|
||||
Task.async(fn -> send_subscription(activity, subscription, options) end)
|
||||
end)
|
||||
|> Task.await_many(10_000)
|
||||
|
||||
{:ok, :sent}
|
||||
else
|
||||
{:ok, :skipped}
|
||||
|
|
Loading…
Reference in New Issue