Various typespec and compilation improvements
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -12,7 +12,7 @@ defmodule Mobilizon.Web.Email.Activity do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Web.Email
|
||||
|
||||
@spec direct_activity(String.t(), list(), String.t()) ::
|
||||
@spec direct_activity(String.t(), list(), Keyword.t()) ::
|
||||
Bamboo.Email.t()
|
||||
def direct_activity(
|
||||
email,
|
||||
|
||||
@@ -5,6 +5,7 @@ defmodule Mobilizon.Web.Email.Mailer do
|
||||
use Bamboo.Mailer, otp_app: :mobilizon
|
||||
alias Mobilizon.Service.ErrorReporting.Sentry
|
||||
|
||||
@spec send_email_later(Bamboo.Email.t()) :: Bamboo.Email.t()
|
||||
def send_email_later(email) do
|
||||
Mobilizon.Web.Email.Mailer.deliver_later!(email)
|
||||
rescue
|
||||
@@ -17,6 +18,7 @@ defmodule Mobilizon.Web.Email.Mailer do
|
||||
reraise error, __STACKTRACE__
|
||||
end
|
||||
|
||||
@spec send_email(Bamboo.Email.t()) :: Bamboo.Email.t() | {Bamboo.Email.t(), any()}
|
||||
def send_email(email) do
|
||||
Mobilizon.Web.Email.Mailer.deliver_now!(email)
|
||||
rescue
|
||||
|
||||
@@ -50,7 +50,6 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
Bamboo.Email.t()
|
||||
def participation_updated(user, participant, locale \\ "en")
|
||||
|
||||
@spec participation_updated(User.t(), Participant.t(), String.t()) :: Bamboo.Email.t()
|
||||
def participation_updated(
|
||||
%User{email: email},
|
||||
%Participant{} = participant,
|
||||
@@ -58,7 +57,6 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
),
|
||||
do: participation_updated(email, participant, locale)
|
||||
|
||||
@spec participation_updated(String.t(), Participant.t(), String.t()) :: Bamboo.Email.t()
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: event, role: :rejected},
|
||||
@@ -79,7 +77,6 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|> render(:event_participation_rejected)
|
||||
end
|
||||
|
||||
@spec participation_updated(String.t(), Participant.t(), String.t()) :: Bamboo.Email.t()
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: %Event{join_options: :free} = event, role: :participant},
|
||||
@@ -100,7 +97,6 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|> render(:event_participation_confirmed)
|
||||
end
|
||||
|
||||
@spec participation_updated(String.t(), Participant.t(), String.t()) :: Bamboo.Email.t()
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: event, role: :participant},
|
||||
|
||||
@@ -57,6 +57,7 @@ defmodule Mobilizon.Web.Email.User do
|
||||
|> render(:password_reset)
|
||||
end
|
||||
|
||||
@spec check_confirmation_token(String.t()) :: {:ok, User.t()} | {:error, :invalid_token}
|
||||
def check_confirmation_token(token) when is_binary(token) do
|
||||
with %User{} = user <- Users.get_user_by_activation_token(token),
|
||||
{:ok, %User{} = user} <-
|
||||
@@ -86,7 +87,7 @@ defmodule Mobilizon.Web.Email.User do
|
||||
end
|
||||
end
|
||||
|
||||
@spec send_confirmation_email(User.t(), String.t()) :: {:ok, Bamboo.Email.t()} | {:error, any()}
|
||||
@spec send_confirmation_email(User.t(), String.t()) :: Bamboo.Email.t()
|
||||
def send_confirmation_email(%User{} = user, locale \\ "en") do
|
||||
user
|
||||
|> Email.User.confirmation_email(locale)
|
||||
@@ -96,7 +97,8 @@ defmodule Mobilizon.Web.Email.User do
|
||||
@doc """
|
||||
Check that the provided token is correct and update provided password
|
||||
"""
|
||||
@spec check_reset_password_token(String.t(), String.t()) :: tuple
|
||||
@spec check_reset_password_token(String.t(), String.t()) ::
|
||||
{:ok, User.t()} | {:error, String.t()}
|
||||
def check_reset_password_token(password, token) do
|
||||
with %User{} = user <- Users.get_user_by_reset_password_token(token),
|
||||
{:ok, %User{} = user} <-
|
||||
|
||||
Reference in New Issue
Block a user