Add Push notifications backend support

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-05-06 12:27:04 +02:00
parent 4f6e203ced
commit 9f5e3a39ec
14 changed files with 321 additions and 26 deletions

View File

@@ -14,12 +14,12 @@ defmodule Mobilizon.Service.Notifier do
@doc """
Sends one or multiple notifications from an activity
"""
@callback send(User.t(), Activity.t()) :: {:ok, any()} | {:error, String.t()}
@callback send(User.t(), Activity.t(), Keyword.t()) :: {:ok, any()} | {:error, String.t()}
@callback send(User.t(), list(Activity.t())) :: {:ok, any()} | {:error, String.t()}
@callback send(User.t(), list(Activity.t()), Keyword.t()) :: {:ok, any()} | {:error, String.t()}
def notify(%User{} = user, %Activity{} = activity, opts \\ []) do
Enum.each(providers(opts), & &1.send(user, activity))
Enum.each(providers(opts), & &1.send(user, activity, opts))
end
@spec providers(Keyword.t()) :: list()