Merge branch 'email-spam' into 'main'

Move mailer from Bamboo to Swoosh

Closes #491

See merge request framasoft/mobilizon!1203
This commit is contained in:
Thomas Citharel 2022-04-05 11:21:24 +00:00
commit 4b9a38b2a7
37 changed files with 405 additions and 554 deletions

View File

@ -19,7 +19,6 @@ MOBILIZON_REPLY_EMAIL=contact@mobilizon.lan
# Email settings # Email settings
MOBILIZON_SMTP_SERVER=localhost MOBILIZON_SMTP_SERVER=localhost
MOBILIZON_SMTP_PORT=25 MOBILIZON_SMTP_PORT=25
MOBILIZON_SMTP_HOSTNAME=localhost
MOBILIZON_SMTP_USERNAME=noreply@mobilizon.lan MOBILIZON_SMTP_USERNAME=noreply@mobilizon.lan
MOBILIZON_SMTP_PASSWORD=password MOBILIZON_SMTP_PASSWORD=password
MOBILIZON_SMTP_SSL=false MOBILIZON_SMTP_SSL=false

View File

@ -1,2 +1,2 @@
elixir 1.13.3-otp-24 elixir 1.13.3-otp-24
erlang 24.3.2 erlang 24.3.3

View File

@ -106,9 +106,8 @@ config :mobilizon, :media_proxy,
] ]
config :mobilizon, Mobilizon.Web.Email.Mailer, config :mobilizon, Mobilizon.Web.Email.Mailer,
adapter: Bamboo.SMTPAdapter, adapter: Swoosh.Adapters.SMTP,
server: "localhost", relay: "localhost",
hostname: "localhost",
# usually 25, 465 or 587 # usually 25, 465 or 587
port: 25, port: 25,
username: nil, username: nil,

View File

@ -67,7 +67,7 @@ config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation # Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime config :phoenix, :plug_init_mode, :runtime
config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Bamboo.LocalAdapter config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Swoosh.Adapters.Local
# Configure your database # Configure your database
config :mobilizon, Mobilizon.Storage.Repo, config :mobilizon, Mobilizon.Storage.Repo,

View File

@ -43,9 +43,8 @@ config :mobilizon, Mobilizon.Storage.Repo,
pool_size: 10 pool_size: 10
config :mobilizon, Mobilizon.Web.Email.Mailer, config :mobilizon, Mobilizon.Web.Email.Mailer,
adapter: Bamboo.SMTPAdapter, adapter: Swoosh.Adapters.SMTP,
server: System.get_env("MOBILIZON_SMTP_SERVER", "localhost"), relay: System.get_env("MOBILIZON_SMTP_SERVER", "localhost"),
hostname: System.get_env("MOBILIZON_SMTP_HOSTNAME", "localhost"),
port: System.get_env("MOBILIZON_SMTP_PORT", "25"), port: System.get_env("MOBILIZON_SMTP_PORT", "25"),
username: System.get_env("MOBILIZON_SMTP_USERNAME", nil), username: System.get_env("MOBILIZON_SMTP_USERNAME", nil),
password: System.get_env("MOBILIZON_SMTP_PASSWORD", nil), password: System.get_env("MOBILIZON_SMTP_PASSWORD", nil),

View File

@ -54,7 +54,7 @@ config :mobilizon, :ldap,
bind_uid: System.get_env("LDAP_BIND_UID"), bind_uid: System.get_env("LDAP_BIND_UID"),
bind_password: System.get_env("LDAP_BIND_PASSWORD") bind_password: System.get_env("LDAP_BIND_PASSWORD")
config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Bamboo.TestAdapter config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Swoosh.Adapters.Test
config :mobilizon, Mobilizon.Web.Upload, filters: [], link_name: false config :mobilizon, Mobilizon.Web.Upload, filters: [], link_name: false

View File

@ -22,7 +22,7 @@ defmodule Mobilizon.Federation.ActivityPub.Actions.Flag do
Enum.each(Users.list_moderators(), fn moderator -> Enum.each(Users.list_moderators(), fn moderator ->
moderator moderator
|> Admin.report(report) |> Admin.report(report)
|> Mailer.send_email_later() |> Mailer.send_email()
end) end)
{:ok, activity, report} {:ok, activity, report}

View File

@ -323,11 +323,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
if notify do if notify do
updated_user updated_user
|> Email.Admin.user_email_change_old(old_email) |> Email.Admin.user_email_change_old(old_email)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
updated_user updated_user
|> Email.Admin.user_email_change_new(old_email) |> Email.Admin.user_email_change_new(old_email)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
{:ok, updated_user} {:ok, updated_user}
@ -353,7 +353,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
if notify do if notify do
user user
|> Email.Admin.user_role_change(old_role) |> Email.Admin.user_role_change(old_role)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
{:ok, user} {:ok, user}
@ -375,7 +375,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
if notify do if notify do
user user
|> Email.Admin.user_confirmation() |> Email.Admin.user_confirmation()
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
{:ok, user} {:ok, user}

View File

@ -74,7 +74,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
participant, participant,
Map.get(args, :locale, "en") Map.get(args, :locale, "en")
) )
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
{:ok, participant} {:ok, participant}

View File

@ -148,9 +148,8 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
with {:ok, email} <- lowercase_domain(email), with {:ok, email} <- lowercase_domain(email),
:registration_ok <- check_registration_config(email), :registration_ok <- check_registration_config(email),
:not_deny_listed <- check_registration_denylist(email), :not_deny_listed <- check_registration_denylist(email),
{:ok, %User{} = user} <- Users.register(%{args | email: email}), {:ok, %User{} = user} <- Users.register(%{args | email: email}) do
%Bamboo.Email{} <- Email.User.send_confirmation_email(user, Map.get(args, :locale, "en"))
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en")) do
{:ok, user} {:ok, user}
else else
{:error, :invalid_email} -> {:error, :invalid_email} ->
@ -285,9 +284,8 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
{:ok, %User{locale: locale} = user} <- {:ok, %User{locale: locale} = user} <-
Users.get_user_by_email(email, activated: true, unconfirmed: false), Users.get_user_by_email(email, activated: true, unconfirmed: false),
{:can_reset_password, true} <- {:can_reset_password, true} <-
{:can_reset_password, Authenticator.can_reset_password?(user)}, {:can_reset_password, Authenticator.can_reset_password?(user)} do
{:ok, %Bamboo.Email{}} <- Email.User.send_password_reset_email(user, Map.get(args, :locale, locale))
Email.User.send_password_reset_email(user, Map.get(args, :locale, locale)) do
{:ok, email} {:ok, email}
else else
{:can_reset_password, false} -> {:can_reset_password, false} ->
@ -456,11 +454,11 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
{:ok, %User{} = user} -> {:ok, %User{} = user} ->
user user
|> Email.User.send_email_reset_old_email() |> Email.User.send_email_reset_old_email()
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
user user
|> Email.User.send_email_reset_new_email() |> Email.User.send_email_reset_new_email()
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
{:ok, user} {:ok, user}

View File

@ -35,7 +35,7 @@ defmodule Mobilizon.Service.Workers.Notification do
%Participant{participant | event: event, actor: actor}, %Participant{participant | event: event, actor: actor},
locale locale
) )
|> Mailer.send_email_later() |> Mailer.send_email()
:ok :ok
end end
@ -65,7 +65,7 @@ defmodule Mobilizon.Service.Workers.Notification do
end) do end) do
user user
|> Notification.on_day_notification(participations, total, locale) |> Notification.on_day_notification(participations, total, locale)
|> Mailer.send_email_later() |> Mailer.send_email()
:ok :ok
else else
@ -99,7 +99,7 @@ defmodule Mobilizon.Service.Workers.Notification do
end) do end) do
user user
|> Notification.weekly_notification(participations, total, locale) |> Notification.weekly_notification(participations, total, locale)
|> Mailer.send_email_later() |> Mailer.send_email()
:ok :ok
else else
@ -121,7 +121,7 @@ defmodule Mobilizon.Service.Workers.Notification do
Events.list_participants_for_event(event_id, [:not_approved]) do Events.list_participants_for_event(event_id, [:not_approved]) do
user user
|> Notification.pending_participation_notification(event, total) |> Notification.pending_participation_notification(event, total)
|> Mailer.send_email_later() |> Mailer.send_email()
:ok :ok
else else

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Activity do
@moduledoc """ @moduledoc """
Handles emails sent about activity notifications. Handles emails sent about activity notifications.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.Activities.Activity alias Mobilizon.Activities.Activity
@ -12,8 +11,7 @@ defmodule Mobilizon.Web.Email.Activity do
alias Mobilizon.Config alias Mobilizon.Config
alias Mobilizon.Web.Email alias Mobilizon.Web.Email
@spec direct_activity(String.t(), list(), Keyword.t()) :: @spec direct_activity(String.t(), list(), Keyword.t()) :: Swoosh.Email.t()
Bamboo.Email.t()
def direct_activity( def direct_activity(
email, email,
activities, activities,
@ -28,17 +26,19 @@ defmodule Mobilizon.Web.Email.Activity do
chunked_activities = chunk_activities(activities) chunked_activities = chunk_activities(activities)
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:email_direct_activity, %{
|> assign(:activities, chunked_activities) locale: locale,
|> assign(:total_number_activities, length(activities)) subject: subject,
|> assign(:single_activity, single_activity) activities: chunked_activities,
|> assign(:recap, recap) total_number_activities: length(activities),
|> render(:email_direct_activity) single_activity: single_activity,
recap: recap
})
end end
@spec anonymous_activity(String.t(), Activity.t(), Keyword.t()) :: Bamboo.Email.t() @spec anonymous_activity(String.t(), Activity.t(), Keyword.t()) :: Swoosh.Email.t()
def anonymous_activity(email, %Activity{subject_params: subject_params} = activity, options) do def anonymous_activity(email, %Activity{subject_params: subject_params} = activity, options) do
locale = Keyword.get(options, :locale, "en") locale = Keyword.get(options, :locale, "en")
@ -49,11 +49,13 @@ defmodule Mobilizon.Web.Email.Activity do
event: subject_params["event_title"] event: subject_params["event_title"]
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:subject, subject) |> Email.base_email()
|> assign(:activity, activity) |> render_body(:email_anonymous_activity, %{
|> assign(:locale, locale) subject: subject,
|> render(:email_anonymous_activity) activity: activity,
locale: locale
})
end end
@spec chunk_activities(list()) :: map() @spec chunk_activities(list()) :: map()

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Actor do
@moduledoc """ @moduledoc """
Handles emails sent about actors status. Handles emails sent about actors status.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.Actors.Actor alias Mobilizon.Actors.Actor
@ -43,14 +42,16 @@ defmodule Mobilizon.Web.Email.Actor do
subject = gettext("Your participation to %{event} has been cancelled!", event: event.title) subject = gettext("Your participation to %{event} has been cancelled!", event: event.title)
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:actor, suspended) |> render_body(:actor_suspension_participants, %{
|> assign(:event, event) locale: locale,
|> assign(:role, member_role) actor: suspended,
|> assign(:subject, subject) event: event,
|> render(:actor_suspension_participants) role: member_role,
|> Email.Mailer.send_email_later() subject: subject
})
|> Email.Mailer.send_email()
:ok :ok
end end

View File

@ -3,9 +3,7 @@ defmodule Mobilizon.Web.Email.Admin do
Handles emails sent to admins. Handles emails sent to admins.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
@ -15,7 +13,7 @@ defmodule Mobilizon.Web.Email.Admin do
alias Mobilizon.Web.Email alias Mobilizon.Web.Email
@spec report(User.t(), Report.t()) :: Bamboo.Email.t() @spec report(User.t(), Report.t()) :: Swoosh.Email.t()
def report(%User{email: email} = user, %Report{} = report) do def report(%User{email: email} = user, %Report{} = report) do
locale = Map.get(user, :locale, "en") locale = Map.get(user, :locale, "en")
Gettext.put_locale(locale) Gettext.put_locale(locale)
@ -26,14 +24,12 @@ defmodule Mobilizon.Web.Email.Admin do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:report, %{locale: locale, subject: subject, report: report})
|> assign(:report, report)
|> render(:report)
end end
@spec user_email_change_old(User.t(), String.t()) :: Bamboo.Email.t() @spec user_email_change_old(User.t(), String.t()) :: Swoosh.Email.t()
def user_email_change_old( def user_email_change_old(
%User{ %User{
locale: user_locale, locale: user_locale,
@ -49,16 +45,18 @@ defmodule Mobilizon.Web.Email.Admin do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: old_email, subject: subject) [to: old_email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:admin_user_email_changed_old, %{
|> assign(:new_email, new_email) locale: user_locale,
|> assign(:old_email, old_email) subject: subject,
|> assign(:offer_unsupscription, false) new_email: new_email,
|> render(:admin_user_email_changed_old) old_email: old_email,
offer_unsupscription: false
})
end end
@spec user_email_change_new(User.t(), String.t()) :: Bamboo.Email.t() @spec user_email_change_new(User.t(), String.t()) :: Swoosh.Email.t()
def user_email_change_new( def user_email_change_new(
%User{ %User{
locale: user_locale, locale: user_locale,
@ -74,16 +72,18 @@ defmodule Mobilizon.Web.Email.Admin do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: new_email, subject: subject) [to: old_email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:admin_user_email_changed_new, %{
|> assign(:old_email, old_email) locale: user_locale,
|> assign(:new_email, new_email) subject: subject,
|> assign(:offer_unsupscription, false) new_email: new_email,
|> render(:admin_user_email_changed_new) old_email: old_email,
offer_unsupscription: false
})
end end
@spec user_role_change(User.t(), atom()) :: Bamboo.Email.t() @spec user_role_change(User.t(), atom()) :: Swoosh.Email.t()
def user_role_change( def user_role_change(
%User{ %User{
locale: user_locale, locale: user_locale,
@ -100,16 +100,18 @@ defmodule Mobilizon.Web.Email.Admin do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:admin_user_role_changed, %{
|> assign(:old_role, old_role) locale: user_locale,
|> assign(:new_role, new_role) subject: subject,
|> assign(:offer_unsupscription, false) old_role: old_role,
|> render(:admin_user_role_changed) new_role: new_role,
offer_unsupscription: false
})
end end
@spec user_confirmation(User.t()) :: Bamboo.Email.t() @spec user_confirmation(User.t()) :: Swoosh.Email.t()
def user_confirmation(%User{ def user_confirmation(%User{
locale: user_locale, locale: user_locale,
email: email email: email
@ -122,10 +124,12 @@ defmodule Mobilizon.Web.Email.Admin do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:admin_user_confirmation, %{
|> assign(:offer_unsupscription, false) locale: user_locale,
|> render(:admin_user_confirmation) subject: subject,
offer_unsupscription: false
})
end end
end end

View File

@ -3,49 +3,29 @@ defmodule Mobilizon.Web.Email do
The Email context. The Email context.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView, layout: {Mobilizon.Web.EmailView, :email}
alias Mobilizon.{Config, Events} alias Mobilizon.{Config, Events}
alias Mobilizon.Events.Event alias Mobilizon.Events.Event
alias Mobilizon.Service.Export.ICalendar alias Mobilizon.Service.Export.ICalendar
alias Mobilizon.Web.EmailView alias Mobilizon.Web.EmailView
@spec base_email(keyword()) :: Bamboo.Email.t() @spec base_email(keyword()) :: Swoosh.Email.t()
def base_email(args) do def base_email(args) do
args [reply_to: Config.instance_email_reply_to() || Config.instance_email_from()]
|> new_email() |> Keyword.merge(args)
|> new()
|> from({Config.instance_name(), Config.instance_email_from()}) |> from({Config.instance_name(), Config.instance_email_from()})
|> put_header("Reply-To", Config.instance_email_reply_to())
|> maybe_put_date_header()
|> maybe_put_message_id()
|> assign(:jsonLDMetadata, nil) |> assign(:jsonLDMetadata, nil)
|> assign(:instance_name, Config.instance_name()) |> assign(:instance_name, Config.instance_name())
|> assign(:offer_unsupscription, true) |> assign(:offer_unsupscription, true)
|> put_html_layout({EmailView, "email.html"}) |> put_layout({EmailView, :email})
|> put_text_layout({EmailView, "email.text"})
end end
# Generating an UUID randomly causes Bamboo.Test.assert_delivered_email/1 to fail def add_event_attachment(%Swoosh.Email{} = email, %Event{id: event_id}) do
defp maybe_put_message_id(email) do
if Application.fetch_env!(:mobilizon, :env) == :test do
put_header(email, "Message-Id", "TEST_ENV_MESSAGE_ID@#{Config.instance_hostname()}")
else
email
end
end
defp maybe_put_date_header(email) do
if Application.fetch_env!(:mobilizon, :env) == :test do
put_header(email, "Date", "REMOVED FOR TESTING")
else
email
end
end
def add_event_attachment(%Bamboo.Email{} = email, %Event{id: event_id}) do
with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id), with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id),
{:ok, event_ics_data} <- ICalendar.export_event(event) do {:ok, event_ics_data} <- ICalendar.export_event(event) do
put_attachment(email, %Bamboo.Attachment{ attachment(email, %Swoosh.Attachment{
filename: "#{Slugger.slugify_downcase(event.title)}.ics", filename: "#{Slugger.slugify_downcase(event.title)}.ics",
content_type: "text/calendar", content_type: "text/calendar",
data: event_ics_data data: event_ics_data

View File

@ -3,9 +3,7 @@ defmodule Mobilizon.Web.Email.Event do
Handles emails sent about events. Handles emails sent about events.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
@ -20,8 +18,8 @@ defmodule Mobilizon.Web.Email.Event do
@important_changes [:title, :begins_on, :ends_on, :status, :physical_address] @important_changes [:title, :begins_on, :ends_on, :status, :physical_address]
@spec event_updated( @spec event_updated(
Participant.t(),
String.t(), String.t(),
Participant.t(),
Actor.t(), Actor.t(),
Event.t(), Event.t(),
Event.t(), Event.t(),
@ -29,7 +27,7 @@ defmodule Mobilizon.Web.Email.Event do
String.t(), String.t(),
String.t() String.t()
) :: ) ::
Bamboo.Email.t() Swoosh.Email.t()
def event_updated( def event_updated(
email, email,
%Participant{} = participant, %Participant{} = participant,
@ -53,16 +51,18 @@ defmodule Mobilizon.Web.Email.Event do
|> ObjectView.render(%{participant: %Participant{participant | event: event, actor: actor}}) |> ObjectView.render(%{participant: %Participant{participant | event: event, actor: actor}})
|> Jason.encode!() |> Jason.encode!()
Email.base_email(to: {Actor.display_name(actor), email}, subject: subject) [to: {Actor.display_name(actor), email}, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:event, event)
|> assign(:old_event, old_event)
|> assign(:changes, changes)
|> assign(:subject, subject)
|> assign(:timezone, timezone)
|> assign(:jsonLDMetadata, json_ld)
|> Email.add_event_attachment(event) |> Email.add_event_attachment(event)
|> render(:event_updated) |> render_body(:event_updated, %{
locale: locale,
event: event,
old_event: old_event,
changes: changes,
subject: subject,
timezone: timezone,
jsonLDMetadata: json_ld
})
end end
@spec calculate_event_diff_and_send_notifications(Event.t(), Event.t(), map()) :: {:ok, :ok} @spec calculate_event_diff_and_send_notifications(Event.t(), Event.t(), map()) :: {:ok, :ok}
@ -101,7 +101,7 @@ defmodule Mobilizon.Web.Email.Event do
Event.t(), Event.t(),
Event.t(), Event.t(),
MapSet.t() MapSet.t()
) :: Bamboo.Email.t() ) :: Swoosh.Email.t()
defp send_notification_for_event_update_to_participant( defp send_notification_for_event_update_to_participant(
{%Participant{} = participant, %Actor{} = actor, {%Participant{} = participant, %Actor{} = actor,
%User{locale: locale, email: email} = _user, %Setting{timezone: timezone}}, %User{locale: locale, email: email} = _user, %Setting{timezone: timezone}},
@ -171,7 +171,7 @@ defmodule Mobilizon.Web.Email.Event do
MapSet.t(), MapSet.t(),
String.t(), String.t(),
String.t() String.t()
) :: Bamboo.Email.t() ) :: Swoosh.Email.t()
defp do_send_notification_for_event_update_to_participant( defp do_send_notification_for_event_update_to_participant(
participant, participant,
email, email,
@ -184,6 +184,6 @@ defmodule Mobilizon.Web.Email.Event do
) do ) do
email email
|> event_updated(participant, actor, old_event, event, diff, timezone, locale) |> event_updated(participant, actor, old_event, event, diff, timezone, locale)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
end end

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Follow do
@moduledoc """ @moduledoc """
Handles emails sent about (instance) follow. Handles emails sent about (instance) follow.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.Users alias Mobilizon.Users
@ -57,12 +56,10 @@ defmodule Mobilizon.Web.Email.Follow do
) )
end end
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:follower, follower) |> render_body(:instance_follow, %{locale: locale, follower: follower, subject: subject})
|> assign(:subject, subject) |> Email.Mailer.send_email()
|> render(:instance_follow)
|> Email.Mailer.send_email_later()
:ok :ok
end end

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Group do
@moduledoc """ @moduledoc """
Handles emails sent about group changes. Handles emails sent about group changes.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.{Actors, Config, Users} alias Mobilizon.{Actors, Config, Users}
@ -47,14 +46,16 @@ defmodule Mobilizon.Web.Email.Group do
event: event.title event: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:group, group) |> render_body(:event_group_follower_notification, %{
|> assign(:event, event) locale: locale,
|> assign(:timezone, timezone) group: group,
|> assign(:subject, subject) event: event,
|> render(:event_group_follower_notification) timezone: timezone,
|> Email.Mailer.send_email_later() subject: subject
})
|> Email.Mailer.send_email()
:ok :ok
end end
@ -92,13 +93,15 @@ defmodule Mobilizon.Web.Email.Group do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:group, group) |> render_body(:group_suspension, %{
|> assign(:role, member_role) locale: locale,
|> assign(:subject, subject) group: group,
|> render(:group_suspension) role: member_role,
|> Email.Mailer.send_email_later() subject: subject
})
|> Email.Mailer.send_email()
:ok :ok
end end

View File

@ -2,25 +2,12 @@ defmodule Mobilizon.Web.Email.Mailer do
@moduledoc """ @moduledoc """
Mobilizon Mailer. Mobilizon Mailer.
""" """
use Bamboo.Mailer, otp_app: :mobilizon use Swoosh.Mailer, otp_app: :mobilizon
alias Mobilizon.Service.ErrorReporting.Sentry alias Mobilizon.Service.ErrorReporting.Sentry
@spec send_email_later(Bamboo.Email.t()) :: Bamboo.Email.t() @spec send_email(Swoosh.Email.t()) :: Swoosh.Email.t()
def send_email_later(email) do
Mobilizon.Web.Email.Mailer.deliver_later!(email)
rescue
error ->
Sentry.capture_exception(error,
stacktrace: __STACKTRACE__,
extra: %{extra: "Error while sending email"}
)
reraise error, __STACKTRACE__
end
@spec send_email(Bamboo.Email.t()) :: Bamboo.Email.t() | {Bamboo.Email.t(), any()}
def send_email(email) do def send_email(email) do
Mobilizon.Web.Email.Mailer.deliver_now!(email) Mobilizon.Web.Email.Mailer.deliver(email)
rescue rescue
error -> error ->
Sentry.capture_exception(error, Sentry.capture_exception(error,

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Member do
@moduledoc """ @moduledoc """
Handles emails sent about group members. Handles emails sent about group members.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.{Actors, Users} alias Mobilizon.{Actors, Users}
@ -34,13 +33,15 @@ defmodule Mobilizon.Web.Email.Member do
group: group.name group: group.name
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:inviter, inviter) |> render_body(:group_invite, %{
|> assign(:group, group) locale: locale,
|> assign(:subject, subject) inviter: inviter,
|> render(:group_invite) group: group,
|> Email.Mailer.send_email_later() subject: subject
})
|> Email.Mailer.send_email()
:ok :ok
end end
@ -62,12 +63,10 @@ defmodule Mobilizon.Web.Email.Member do
group: Actor.display_name(group) group: Actor.display_name(group)
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:group, group) |> render_body(:group_membership_approval, %{locale: locale, group: group, subject: subject})
|> assign(:subject, subject) |> Email.Mailer.send_email()
|> render(:group_membership_approval)
|> Email.Mailer.send_email_later()
:ok :ok
end end
@ -91,12 +90,14 @@ defmodule Mobilizon.Web.Email.Member do
group: Actor.display_name(group) group: Actor.display_name(group)
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:group, group) |> render_body(:group_membership_rejection, %{
|> assign(:subject, subject) locale: locale,
|> render(:group_membership_rejection) group: group,
|> Email.Mailer.send_email_later() subject: subject
})
|> Email.Mailer.send_email()
:ok :ok
end end
@ -115,12 +116,10 @@ defmodule Mobilizon.Web.Email.Member do
group: Actor.display_name(group) group: Actor.display_name(group)
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:group, group) |> render_body(:group_member_removal, %{locale: locale, group: group, subject: subject})
|> assign(:subject, subject) |> Email.Mailer.send_email()
|> render(:group_member_removal)
|> Email.Mailer.send_email_later()
:ok :ok
end end

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Notification do
@moduledoc """ @moduledoc """
Handles emails sent about event notifications. Handles emails sent about event notifications.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.Events.{Event, Participant} alias Mobilizon.Events.{Event, Participant}
@ -13,7 +12,7 @@ defmodule Mobilizon.Web.Email.Notification do
alias Mobilizon.Web.JsonLD.ObjectView alias Mobilizon.Web.JsonLD.ObjectView
@spec before_event_notification(String.t(), Participant.t(), String.t()) :: @spec before_event_notification(String.t(), Participant.t(), String.t()) ::
Bamboo.Email.t() Swoosh.Email.t()
def before_event_notification( def before_event_notification(
email, email,
%Participant{event: event, role: :participant} = participant, %Participant{event: event, role: :participant} = participant,
@ -27,17 +26,19 @@ defmodule Mobilizon.Web.Email.Notification do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:participant, participant)
|> assign(:subject, subject)
|> assign(:jsonLDMetadata, build_json_ld(participant))
|> Email.add_event_attachment(event) |> Email.add_event_attachment(event)
|> render(:before_event_notification) |> render_body(:before_event_notification, %{
locale: locale,
participant: participant,
subject: subject,
jsonLDMetadata: build_json_ld(participant)
})
end end
@spec on_day_notification(User.t(), list(Participant.t()), pos_integer(), String.t()) :: @spec on_day_notification(User.t(), list(Participant.t()), pos_integer(), String.t()) ::
Bamboo.Email.t() Swoosh.Email.t()
def on_day_notification( def on_day_notification(
%User{email: email, settings: %Setting{timezone: timezone}}, %User{email: email, settings: %Setting{timezone: timezone}},
participations, participations,
@ -52,19 +53,21 @@ defmodule Mobilizon.Web.Email.Notification do
nb_events: total nb_events: total
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:participation, participation) |> render_body(:on_day_notification, %{
|> assign(:participations, participations) locale: locale,
|> assign(:total, total) participation: participation,
|> assign(:timezone, timezone) participations: participations,
|> assign(:subject, subject) subject: subject,
|> assign(:jsonLDMetadata, build_json_ld(participations)) total: total,
|> render(:on_day_notification) timezone: timezone,
jsonLDMetadata: build_json_ld(participations)
})
end end
@spec weekly_notification(User.t(), list(Participant.t()), pos_integer(), String.t()) :: @spec weekly_notification(User.t(), list(Participant.t()), pos_integer(), String.t()) ::
Bamboo.Email.t() Swoosh.Email.t()
def weekly_notification( def weekly_notification(
%User{email: email, settings: %Setting{timezone: timezone}}, %User{email: email, settings: %Setting{timezone: timezone}},
participations, participations,
@ -79,18 +82,20 @@ defmodule Mobilizon.Web.Email.Notification do
nb_events: total nb_events: total
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:participation, participation) |> render_body(:notification_each_week, %{
|> assign(:participations, participations) locale: locale,
|> assign(:total, total) participation: participation,
|> assign(:timezone, timezone) participations: participations,
|> assign(:subject, subject) subject: subject,
|> assign(:jsonLDMetadata, build_json_ld(participations)) total: total,
|> render(:notification_each_week) timezone: timezone,
jsonLDMetadata: build_json_ld(participations)
})
end end
@spec pending_participation_notification(User.t(), Event.t(), pos_integer()) :: Bamboo.Email.t() @spec pending_participation_notification(User.t(), Event.t(), pos_integer()) :: Swoosh.Email.t()
def pending_participation_notification( def pending_participation_notification(
%User{locale: locale, email: email, settings: %Setting{timezone: timezone}}, %User{locale: locale, email: email, settings: %Setting{timezone: timezone}},
%Event{} = event, %Event{} = event,
@ -107,13 +112,15 @@ defmodule Mobilizon.Web.Email.Notification do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:event, event) |> render_body(:pending_participation_notification, %{
|> assign(:total, total) locale: locale,
|> assign(:timezone, timezone) event: event,
|> assign(:subject, subject) subject: subject,
|> render(:pending_participation_notification) total: total,
timezone: timezone
})
end end
@spec build_json_ld(Participant.t()) :: String.t() @spec build_json_ld(Participant.t()) :: String.t()

View File

@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Participation do
@moduledoc """ @moduledoc """
Handles emails sent about participation. Handles emails sent about participation.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
alias Mobilizon.Actors.Actor alias Mobilizon.Actors.Actor
@ -28,7 +27,7 @@ defmodule Mobilizon.Web.Email.Participation do
email email
|> participation_updated(participation, locale) |> participation_updated(participation, locale)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
:ok :ok
@ -40,14 +39,14 @@ defmodule Mobilizon.Web.Email.Participation do
with %User{locale: locale} = user <- Users.get_user!(user_id) do with %User{locale: locale} = user <- Users.get_user!(user_id) do
user user
|> participation_updated(participation, locale) |> participation_updated(participation, locale)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
:ok :ok
end end
end end
@spec participation_updated(String.t() | User.t(), Participant.t(), String.t()) :: @spec participation_updated(String.t() | User.t(), Participant.t(), String.t()) ::
Bamboo.Email.t() Swoosh.Email.t()
def participation_updated(user, participant, locale \\ "en") def participation_updated(user, participant, locale \\ "en")
def participation_updated( def participation_updated(
@ -70,12 +69,14 @@ defmodule Mobilizon.Web.Email.Participation do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:event, event) |> render_body(:event_participation_rejected, %{
|> assign(:jsonLDMetadata, json_ld(participant)) locale: locale,
|> assign(:subject, subject) event: event,
|> render(:event_participation_rejected) jsonLDMetadata: json_ld(participant),
subject: subject
})
end end
def participation_updated( def participation_updated(
@ -92,12 +93,14 @@ defmodule Mobilizon.Web.Email.Participation do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:event, event) |> render_body(:event_participation_confirmed, %{
|> assign(:subject, subject) locale: locale,
|> assign(:jsonLDMetadata, json_ld(participant)) event: event,
|> render(:event_participation_confirmed) jsonLDMetadata: json_ld(participant),
subject: subject
})
end end
def participation_updated( def participation_updated(
@ -113,17 +116,19 @@ defmodule Mobilizon.Web.Email.Participation do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:event, event)
|> assign(:subject, subject)
|> assign(:jsonLDMetadata, json_ld(participant))
|> Email.add_event_attachment(event) |> Email.add_event_attachment(event)
|> render(:event_participation_approved) |> render_body(:event_participation_approved, %{
locale: locale,
event: event,
jsonLDMetadata: json_ld(participant),
subject: subject
})
end end
@spec anonymous_participation_confirmation(String.t(), Participant.t(), String.t()) :: @spec anonymous_participation_confirmation(String.t(), Participant.t(), String.t()) ::
Bamboo.Email.t() Swoosh.Email.t()
def anonymous_participation_confirmation( def anonymous_participation_confirmation(
email, email,
%Participant{event: event, role: :not_confirmed} = participant, %Participant{event: event, role: :not_confirmed} = participant,
@ -137,12 +142,15 @@ defmodule Mobilizon.Web.Email.Participation do
title: event.title title: event.title
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:participant, participant) |> render_body(:anonymous_participation_confirmation, %{
|> assign(:jsonLDMetadata, json_ld(participant)) locale: locale,
|> assign(:subject, subject) event: event,
|> render(:anonymous_participation_confirmation) jsonLDMetadata: json_ld(participant),
participant: participant,
subject: subject
})
end end
defp json_ld(participant) do defp json_ld(participant) do

View File

@ -3,9 +3,7 @@ defmodule Mobilizon.Web.Email.User do
Handles emails sent to users. Handles emails sent to users.
""" """
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Bamboo.Phoenix
import Mobilizon.Web.Gettext, only: [gettext: 2] import Mobilizon.Web.Gettext, only: [gettext: 2]
@ -17,7 +15,7 @@ defmodule Mobilizon.Web.Email.User do
require Logger require Logger
@spec confirmation_email(User.t(), String.t()) :: Bamboo.Email.t() @spec confirmation_email(User.t(), String.t()) :: Swoosh.Email.t()
def confirmation_email( def confirmation_email(
%User{email: email, confirmation_token: confirmation_token}, %User{email: email, confirmation_token: confirmation_token},
locale \\ "en" locale \\ "en"
@ -30,15 +28,17 @@ defmodule Mobilizon.Web.Email.User do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:token, confirmation_token) |> render_body(:registration_confirmation, %{
|> assign(:subject, subject) locale: locale,
|> assign(:offer_unsupscription, false) token: confirmation_token,
|> render(:registration_confirmation) subject: subject,
offer_unsupscription: false
})
end end
@spec reset_password_email(User.t(), String.t()) :: Bamboo.Email.t() @spec reset_password_email(User.t(), String.t()) :: Swoosh.Email.t()
def reset_password_email( def reset_password_email(
%User{email: email, reset_password_token: reset_password_token}, %User{email: email, reset_password_token: reset_password_token},
locale \\ "en" locale \\ "en"
@ -51,12 +51,14 @@ defmodule Mobilizon.Web.Email.User do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, locale) |> Email.base_email()
|> assign(:token, reset_password_token) |> render_body(:password_reset, %{
|> assign(:subject, subject) locale: locale,
|> assign(:offer_unsupscription, false) token: reset_password_token,
|> render(:password_reset) subject: subject,
offer_unsupscription: false
})
end end
@spec check_confirmation_token(String.t()) :: @spec check_confirmation_token(String.t()) ::
@ -88,18 +90,18 @@ defmodule Mobilizon.Web.Email.User do
{:ok, user} <- {:ok, user} <-
Users.update_user(user, %{ Users.update_user(user, %{
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second) "confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
}), }) do
%Bamboo.Email{} <- send_confirmation_email(user, locale) do send_confirmation_email(user, locale)
Logger.info("Sent confirmation email again to #{user.email}") Logger.info("Sent confirmation email again to #{user.email}")
{:ok, user.email} {:ok, user.email}
end end
end end
@spec send_confirmation_email(User.t(), String.t()) :: Bamboo.Email.t() @spec send_confirmation_email(User.t(), String.t()) :: Swoosh.Email.t()
def send_confirmation_email(%User{} = user, locale \\ "en") do def send_confirmation_email(%User{} = user, locale \\ "en") do
user user
|> Email.User.confirmation_email(locale) |> Email.User.confirmation_email(locale)
|> Email.Mailer.send_email_later() |> Email.Mailer.send_email()
end end
@doc """ @doc """
@ -135,12 +137,12 @@ defmodule Mobilizon.Web.Email.User do
"reset_password_token" => Crypto.random_string(30), "reset_password_token" => Crypto.random_string(30),
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second) "reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
}) })
), ) do
%Bamboo.Email{} = mail <- user_updated
user_updated |> Email.User.reset_password_email(locale)
|> Email.User.reset_password_email(locale) |> Email.Mailer.send_email()
|> Email.Mailer.send_email_later() do
{:ok, mail} {:ok, user.email}
else else
{:error, reason} -> {:error, reason} {:error, reason} -> {:error, reason}
end end
@ -159,12 +161,14 @@ defmodule Mobilizon.Web.Email.User do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: email, subject: subject) [to: email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:email_changed_old, %{
|> assign(:new_email, unconfirmed_email) locale: user_locale,
|> assign(:offer_unsupscription, false) new_email: unconfirmed_email,
|> render(:email_changed_old) subject: subject,
offer_unsupscription: false
})
end end
def send_email_reset_new_email(%User{ def send_email_reset_new_email(%User{
@ -180,12 +184,14 @@ defmodule Mobilizon.Web.Email.User do
instance: Config.instance_name() instance: Config.instance_name()
) )
Email.base_email(to: unconfirmed_email, subject: subject) [to: unconfirmed_email, subject: subject]
|> assign(:locale, user_locale) |> Email.base_email()
|> assign(:subject, subject) |> render_body(:email_changed_new, %{
|> assign(:token, confirmation_token) locale: user_locale,
|> assign(:offer_unsupscription, false) token: confirmation_token,
|> render(:email_changed_new) subject: subject,
offer_unsupscription: false
})
end end
@spec we_can_send_email(User.t(), atom) :: :ok | {:error, :email_too_soon} @spec we_can_send_email(User.t(), atom) :: :ok | {:error, :email_too_soon}

View File

@ -214,7 +214,7 @@ defmodule Mobilizon.Web.Router do
if Application.fetch_env!(:mobilizon, :env) in [:dev, :e2e] do if Application.fetch_env!(:mobilizon, :env) in [:dev, :e2e] do
# If using Phoenix # If using Phoenix
forward("/sent_emails", Bamboo.SentEmailViewerPlug) forward("/sent_emails", Plug.Swoosh.MailboxPreview)
end end
scope "/", Mobilizon.Web do scope "/", Mobilizon.Web do

View File

@ -4,4 +4,7 @@
<%= gettext "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email.", host: @instance_name %> <%= gettext "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email.", host: @instance_name %>
<%= gettext "If you didn't trigger this email, you may safely ignore it." %>
<%= gettext "Activate my account:" %>
<%= Mobilizon.Web.Endpoint.url() <> "/validate/#{@token}" %> <%= Mobilizon.Web.Endpoint.url() <> "/validate/#{@token}" %>

View File

@ -1,10 +1,15 @@
defmodule Mobilizon.Web.EmailView do defmodule Mobilizon.Web.EmailView do
use Mobilizon.Web, :view use Phoenix.View,
root: "lib/web/templates",
pattern: "**/*",
namespace: Mobilizon.Web
alias Mobilizon.Service.Address alias Mobilizon.Service.Address
alias Mobilizon.Service.DateTime, as: DateTimeRenderer alias Mobilizon.Service.DateTime, as: DateTimeRenderer
alias Mobilizon.Web.Router.Helpers, as: Routes
import Mobilizon.Web.Gettext import Mobilizon.Web.Gettext
import Mobilizon.Service.Metadata.Utils, only: [process_description: 1] import Mobilizon.Service.Metadata.Utils, only: [process_description: 1]
import Phoenix.HTML, only: [raw: 1]
defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium), defdelegate datetime_to_string(datetime, locale \\ "en", format \\ :medium),
to: DateTimeRenderer to: DateTimeRenderer

View File

@ -81,7 +81,7 @@ defmodule Mobilizon.Mixfile do
def application do def application do
[ [
mod: {Mobilizon, []}, mod: {Mobilizon, []},
extra_applications: [:logger, :runtime_tools, :guardian, :bamboo, :geolix, :crypto, :cachex] extra_applications: [:logger, :runtime_tools, :guardian, :geolix, :crypto, :cachex]
] ]
end end
@ -152,9 +152,9 @@ defmodule Mobilizon.Mixfile do
{:jason, "~> 1.2"}, {:jason, "~> 1.2"},
{:ecto_enum, "~> 1.4"}, {:ecto_enum, "~> 1.4"},
{:ex_ical, "~> 0.2"}, {:ex_ical, "~> 0.2"},
{:bamboo, "~> 2.1"}, {:swoosh, "~> 1.6"},
{:bamboo_phoenix, "~> 1.0"}, {:gen_smtp, "~> 1.1"},
{:bamboo_smtp, "~> 4.0"}, {:phoenix_swoosh, "~> 1.0"},
{:geolix, "~> 2.0"}, {:geolix, "~> 2.0"},
{:geolix_adapter_mmdb2, "~> 0.6.0"}, {:geolix_adapter_mmdb2, "~> 0.6.0"},
{:absinthe, "~> 1.6"}, {:absinthe, "~> 1.6"},

View File

@ -4,9 +4,6 @@
"absinthe_plug": {:hex, :absinthe_plug, "1.5.8", "38d230641ba9dca8f72f1fed2dfc8abd53b3907d1996363da32434ab6ee5d6ab", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bbb04176647b735828861e7b2705465e53e2cf54ccf5a73ddd1ebd855f996e5a"}, "absinthe_plug": {:hex, :absinthe_plug, "1.5.8", "38d230641ba9dca8f72f1fed2dfc8abd53b3907d1996363da32434ab6ee5d6ab", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bbb04176647b735828861e7b2705465e53e2cf54ccf5a73ddd1ebd855f996e5a"},
"argon2_elixir": {:hex, :argon2_elixir, "3.0.0", "fd4405f593e77b525a5c667282172dd32772d7c4fa58cdecdaae79d2713b6c5f", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "8b753b270af557d51ba13fcdebc0f0ab27a2a6792df72fd5a6cf9cfaffcedc57"}, "argon2_elixir": {:hex, :argon2_elixir, "3.0.0", "fd4405f593e77b525a5c667282172dd32772d7c4fa58cdecdaae79d2713b6c5f", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "8b753b270af557d51ba13fcdebc0f0ab27a2a6792df72fd5a6cf9cfaffcedc57"},
"atomex": {:hex, :atomex, "0.4.1", "7d3910ff7795db91b9af9f8d3e65af7ac69f235adf03484995fc667a36f3edc5", [:mix], [{:xml_builder, "~> 2.1", [hex: :xml_builder, repo: "hexpm", optional: false]}], "hexpm", "f3ac737f7493d42cfddf917f3ac49d60e0a0cf1a35c0712851b07fe8c0a05c7a"}, "atomex": {:hex, :atomex, "0.4.1", "7d3910ff7795db91b9af9f8d3e65af7ac69f235adf03484995fc667a36f3edc5", [:mix], [{:xml_builder, "~> 2.1", [hex: :xml_builder, repo: "hexpm", optional: false]}], "hexpm", "f3ac737f7493d42cfddf917f3ac49d60e0a0cf1a35c0712851b07fe8c0a05c7a"},
"bamboo": {:hex, :bamboo, "2.2.0", "f10a406d2b7f5123eb1f02edfa043c259db04b47ab956041f279eaac776ef5ce", [:mix], [{:hackney, ">= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.4", [hex: :mime, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "8c3b14ba7d2f40cb4be04128ed1e2aff06d91d9413d38bafb4afccffa3ade4fc"},
"bamboo_phoenix": {:hex, :bamboo_phoenix, "1.0.0", "f3cc591ffb163ed0bf935d256f1f4645cd870cf436545601215745fb9cc9953f", [:mix], [{:bamboo, ">= 2.0.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.3.0", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "6db88fbb26019c84a47994bb2bd879c0887c29ce6c559bc6385fd54eb8b37dee"},
"bamboo_smtp": {:hex, :bamboo_smtp, "4.1.0", "ba547be4146ae592f63af05c6c7b7b5195b2b6ca57eeea9d80070b38eacd528b", [:mix], [{:bamboo, "~> 2.2.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:gen_smtp, "~> 1.1.1", [hex: :gen_smtp, repo: "hexpm", optional: false]}], "hexpm", "cb1a2856ab0507d10df609428314aa5e18231e8b1801a5bc6e42f319eeb50ad9"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"cachex": {:hex, :cachex, "3.4.0", "868b2959ea4aeb328c6b60ff66c8d5123c083466ad3c33d3d8b5f142e13101fb", [:mix], [{:eternal, "~> 1.2", [hex: :eternal, repo: "hexpm", optional: false]}, {:jumper, "~> 1.0", [hex: :jumper, repo: "hexpm", optional: false]}, {:sleeplocks, "~> 1.1", [hex: :sleeplocks, repo: "hexpm", optional: false]}, {:unsafe, "~> 1.0", [hex: :unsafe, repo: "hexpm", optional: false]}], "hexpm", "370123b1ab4fba4d2965fb18f87fd758325709787c8c5fce35b3fe80645ccbe5"}, "cachex": {:hex, :cachex, "3.4.0", "868b2959ea4aeb328c6b60ff66c8d5123c083466ad3c33d3d8b5f142e13101fb", [:mix], [{:eternal, "~> 1.2", [hex: :eternal, repo: "hexpm", optional: false]}, {:jumper, "~> 1.0", [hex: :jumper, repo: "hexpm", optional: false]}, {:sleeplocks, "~> 1.1", [hex: :sleeplocks, repo: "hexpm", optional: false]}, {:unsafe, "~> 1.0", [hex: :unsafe, repo: "hexpm", optional: false]}], "hexpm", "370123b1ab4fba4d2965fb18f87fd758325709787c8c5fce35b3fe80645ccbe5"},
"certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"},
@ -69,7 +66,7 @@
"hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"}, "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
"html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"}, "html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
"http_signatures": {:hex, :http_signatures, "0.1.1", "ca7ebc1b61542b163644c8c3b1f0e0f41037d35f2395940d3c6c7deceab41fd8", [:mix], [], "hexpm", "cc3b8a007322cc7b624c0c15eec49ee58ac977254ff529a3c482f681465942a3"}, "http_signatures": {:hex, :http_signatures, "0.1.1", "ca7ebc1b61542b163644c8c3b1f0e0f41037d35f2395940d3c6c7deceab41fd8", [:mix], [], "hexpm", "cc3b8a007322cc7b624c0c15eec49ee58ac977254ff529a3c482f681465942a3"},
"httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"}, "httpoison": {:hex, :httpoison, "1.8.1", "df030d96de89dad2e9983f92b0c506a642d4b1f4a819c96ff77d12796189c63e", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "35156a6d678d6d516b9229e208942c405cf21232edd632327ecfaf4fd03e79e0"},
"hut": {:hex, :hut, "1.3.0", "71f2f054e657c03f959cf1acc43f436ea87580696528ca2a55c8afb1b06c85e7", [:"erlang.mk", :rebar, :rebar3], [], "hexpm", "7e15d28555d8a1f2b5a3a931ec120af0753e4853a4c66053db354f35bf9ab563"}, "hut": {:hex, :hut, "1.3.0", "71f2f054e657c03f959cf1acc43f436ea87580696528ca2a55c8afb1b06c85e7", [:"erlang.mk", :rebar, :rebar3], [], "hexpm", "7e15d28555d8a1f2b5a3a931ec120af0753e4853a4c66053db354f35bf9ab563"},
"icalendar": {:git, "https://github.com/tcitworld/icalendar.git", "e16a3a0b74e07ba79044361fbf5014bed344f2da", []}, "icalendar": {:git, "https://github.com/tcitworld/icalendar.git", "e16a3a0b74e07ba79044361fbf5014bed344f2da", []},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
@ -85,7 +82,7 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, "mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"mimetype_parser": {:hex, :mimetype_parser, "0.1.3", "628ac9fe56aa7edcedb534d68397dd66674ab82493c8ebe39acb9a19b666099d", [:mix], [], "hexpm", "7d8f80c567807ce78cd93c938e7f4b0a20b1aaaaab914bf286f68457d9f7a852"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.3", "628ac9fe56aa7edcedb534d68397dd66674ab82493c8ebe39acb9a19b666099d", [:mix], [], "hexpm", "7d8f80c567807ce78cd93c938e7f4b0a20b1aaaaab914bf286f68457d9f7a852"},
"mix_test_watch": {:hex, :mix_test_watch, "1.1.0", "330bb91c8ed271fe408c42d07e0773340a7938d8a0d281d57a14243eae9dc8c3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "52b6b1c476cbb70fd899ca5394506482f12e5f6b0d6acff9df95c7f1e0812ec3"}, "mix_test_watch": {:hex, :mix_test_watch, "1.1.0", "330bb91c8ed271fe408c42d07e0773340a7938d8a0d281d57a14243eae9dc8c3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "52b6b1c476cbb70fd899ca5394506482f12e5f6b0d6acff9df95c7f1e0812ec3"},
@ -106,7 +103,8 @@
"phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"}, "phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.17.7", "05a42377075868a678d446361effba80cefef19ab98941c01a7a4c7560b29121", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.9 or ~> 1.6.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25eaf41028eb351b90d4f69671874643a09944098fefd0d01d442f40a6091b6f"}, "phoenix_live_view": {:hex, :phoenix_live_view, "0.17.7", "05a42377075868a678d446361effba80cefef19ab98941c01a7a4c7560b29121", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.9 or ~> 1.6.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25eaf41028eb351b90d4f69671874643a09944098fefd0d01d442f40a6091b6f"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.0", "5ea4036a3c8f372e6fbf928c822b16028bcaaf2b26ea83d5775670498af7bd92", [:mix], [], "hexpm", "fe61113eff12693a758080ac595dc86bfe3744d4734520a96f6c1a0d7f13c126"},
"phoenix_swoosh": {:hex, :phoenix_swoosh, "1.0.1", "0db6eb6405a6b06cae4fdf4144659b3f4fee4553e2856fe8a53ba12e9fb21a74", [:mix], [{:finch, "~> 0.8", [hex: :finch, repo: "hexpm", optional: true]}, {:hackney, "~> 1.10", [hex: :hackney, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:swoosh, "~> 1.5", [hex: :swoosh, repo: "hexpm", optional: false]}], "hexpm", "e34890004baec08f0fa12bd8c77bf64bfb4156b84a07fb79da9322fa94bc3781"},
"phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"}, "phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
"plug": {:hex, :plug, "1.13.4", "addb6e125347226e3b11489e23d22a60f7ab74786befb86c14f94fb5f23ca9a4", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "06114c1f2a334212fe3ae567dbb3b1d29fd492c1a09783d52f3d489c1a6f4cf2"}, "plug": {:hex, :plug, "1.13.4", "addb6e125347226e3b11489e23d22a60f7ab74786befb86c14f94fb5f23ca9a4", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "06114c1f2a334212fe3ae567dbb3b1d29fd492c1a09783d52f3d489c1a6f4cf2"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"}, "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
@ -124,7 +122,8 @@
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"struct_access": {:hex, :struct_access, "1.1.2", "a42e6ceedd9b9ea090ee94a6da089d56e16f374dbbc010c3eebdf8be17df286f", [:mix], [], "hexpm", "e4c411dcc0226081b95709909551fc92b8feb1a3476108348ea7e3f6c12e586a"}, "struct_access": {:hex, :struct_access, "1.1.2", "a42e6ceedd9b9ea090ee94a6da089d56e16f374dbbc010c3eebdf8be17df286f", [:mix], [], "hexpm", "e4c411dcc0226081b95709909551fc92b8feb1a3476108348ea7e3f6c12e586a"},
"sweet_xml": {:hex, :sweet_xml, "0.7.2", "4729f997286811fabdd8288f8474e0840a76573051062f066c4b597e76f14f9f", [:mix], [], "hexpm", "6894e68a120f454534d99045ea3325f7740ea71260bc315f82e29731d570a6e8"}, "sweet_xml": {:hex, :sweet_xml, "0.7.2", "4729f997286811fabdd8288f8474e0840a76573051062f066c4b597e76f14f9f", [:mix], [], "hexpm", "6894e68a120f454534d99045ea3325f7740ea71260bc315f82e29731d570a6e8"},
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, "swoosh": {:hex, :swoosh, "1.6.3", "598d3f07641004bedb3eede40057760ae18be1073cff72f079ca1e1fc9cd97b9", [:mix], [{:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "81ff9d7c7c4005a57465a7eb712edd71db51829aef94c8a34c30c5b9e9964adf"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"tesla": {:hex, :tesla, "1.4.4", "bb89aa0c9745190930366f6a2ac612cdf2d0e4d7fff449861baa7875afd797b2", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "d5503a49f9dec1b287567ea8712d085947e247cb11b06bc54adb05bfde466457"}, "tesla": {:hex, :tesla, "1.4.4", "bb89aa0c9745190930366f6a2ac612cdf2d0e4d7fff449861baa7875afd797b2", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "d5503a49f9dec1b287567ea8712d085947e247cb11b06bc54adb05bfde466457"},
"timex": {:hex, :timex, "3.7.7", "3ed093cae596a410759104d878ad7b38e78b7c2151c6190340835515d4a46b8a", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "0ec4b09f25fe311321f9fc04144a7e3affe48eb29481d7a5583849b6c4dfa0a7"}, "timex": {:hex, :timex, "3.7.7", "3ed093cae596a410759104d878ad7b38e78b7c2151c6190340835515d4a46b8a", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "0ec4b09f25fe311321f9fc04144a7e3affe48eb29481d7a5583849b6c4dfa0a7"},
"tz_world": {:hex, :tz_world, "1.0.0", "53366d7ec1d3fb11e1a34ce7c74d21c354195521b3309cdb9e6cc84b266cae83", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:geo, "~> 1.0 or ~> 2.0 or ~> 3.3", [hex: :geo, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9d7aeaa078913b6d486d2a1bf3c1fd380cb16180b93415c7f3fde7cabff478f8"}, "tz_world": {:hex, :tz_world, "1.0.0", "53366d7ec1d3fb11e1a34ce7c74d21c354195521b3309cdb9e6cc84b266cae83", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:geo, "~> 1.0 or ~> 2.0 or ~> 3.3", [hex: :geo, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9d7aeaa078913b6d486d2a1bf3c1fd380cb16180b93415c7f3fde7cabff478f8"},

View File

@ -1,14 +1,13 @@
defmodule Mobilizon.GraphQL.Resolvers.AdminTest do defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
use Bamboo.Test
import Mobilizon.Factory import Mobilizon.Factory
import Swoosh.TestAssertions
alias Mobilizon.Actors.Actor alias Mobilizon.Actors.Actor
alias Mobilizon.Events.Event alias Mobilizon.Events.Event
alias Mobilizon.Federation.ActivityPub.Relay alias Mobilizon.Federation.ActivityPub.Relay
alias Mobilizon.Reports.{Note, Report} alias Mobilizon.Reports.{Note, Report}
alias Mobilizon.Users.User alias Mobilizon.Users.User
alias Mobilizon.Web.Email
alias Mobilizon.GraphQL.{AbsintheHelpers, API} alias Mobilizon.GraphQL.{AbsintheHelpers, API}
@ -563,13 +562,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "email" => "new@email.com", "notify" => false} variables: %{"id" => user.id, "email" => "new@email.com", "notify" => false}
) )
refute_delivered_email( refute_email_sent()
Email.Admin.user_email_change_old(%User{user | email: "new@email.com"}, user.email)
)
refute_delivered_email(
Email.Admin.user_email_change_new(%User{user | email: "new@email.com"}, user.email)
)
assert res["errors"] == nil assert res["errors"] == nil
assert res["data"]["adminUpdateUser"]["email"] == "new@email.com" assert res["data"]["adminUpdateUser"]["email"] == "new@email.com"
@ -584,13 +577,18 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "email" => "new@email.com", "notify" => true} variables: %{"id" => user.id, "email" => "new@email.com", "notify" => true}
) )
assert_delivered_email( assert_email_sent(
Email.Admin.user_email_change_old(%User{user | email: "new@email.com"}, user.email) to: user.email,
subject:
"An administrator manually changed the email attached to your account on Test instance"
) )
assert_delivered_email( # # Swoosh.TestAssertions can't test multiple emails sent
Email.Admin.user_email_change_new(%User{user | email: "new@email.com"}, user.email) # assert_email_sent(
) # to: "new@email.com",
# subject:
# "An administrator manually changed the email attached to your account on Test instance"
# )
assert res["errors"] == nil assert res["errors"] == nil
assert res["data"]["adminUpdateUser"]["email"] == "new@email.com" assert res["data"]["adminUpdateUser"]["email"] == "new@email.com"
@ -639,9 +637,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "role" => "MODERATOR", "notify" => false} variables: %{"id" => user.id, "role" => "MODERATOR", "notify" => false}
) )
refute_delivered_email( refute_email_sent()
Email.Admin.user_role_change(%User{user | role: :moderator}, user.role)
)
assert res["errors"] == nil assert res["errors"] == nil
assert res["data"]["adminUpdateUser"]["role"] == "MODERATOR" assert res["data"]["adminUpdateUser"]["role"] == "MODERATOR"
@ -656,9 +652,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "role" => "MODERATOR", "notify" => true} variables: %{"id" => user.id, "role" => "MODERATOR", "notify" => true}
) )
assert_delivered_email( assert_email_sent(to: user.email)
Email.Admin.user_role_change(%User{user | role: :moderator}, user.role)
)
assert res["errors"] == nil assert res["errors"] == nil
assert res["data"]["adminUpdateUser"]["role"] == "MODERATOR" assert res["data"]["adminUpdateUser"]["role"] == "MODERATOR"
@ -681,7 +675,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "confirmed" => true, "notify" => false} variables: %{"id" => user.id, "confirmed" => true, "notify" => false}
) )
refute_delivered_email(Email.Admin.user_confirmation(user)) refute_email_sent()
assert hd(res["errors"])["message"] == "Can't confirm an already confirmed user" assert hd(res["errors"])["message"] == "Can't confirm an already confirmed user"
end end
@ -695,7 +689,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "confirmed" => false, "notify" => false} variables: %{"id" => user.id, "confirmed" => false, "notify" => false}
) )
refute_delivered_email(Email.Admin.user_confirmation(user)) refute_email_sent()
assert hd(res["errors"])["message"] == "Deconfirming users is not supported" assert hd(res["errors"])["message"] == "Deconfirming users is not supported"
end end
@ -711,7 +705,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "confirmed" => true, "notify" => false} variables: %{"id" => user.id, "confirmed" => true, "notify" => false}
) )
refute_delivered_email(Email.Admin.user_confirmation(user)) refute_email_sent()
assert res["errors"] == nil assert res["errors"] == nil
refute res["data"]["adminUpdateUser"]["confirmedAt"] == nil refute res["data"]["adminUpdateUser"]["confirmedAt"] == nil
@ -728,7 +722,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
variables: %{"id" => user.id, "confirmed" => true, "notify" => true} variables: %{"id" => user.id, "confirmed" => true, "notify" => true}
) )
assert_delivered_email(Email.Admin.user_confirmation(user)) assert_email_sent(to: user.email)
assert res["errors"] == nil assert res["errors"] == nil
refute res["data"]["adminUpdateUser"]["confirmedAt"] == nil refute res["data"]["adminUpdateUser"]["confirmedAt"] == nil

View File

@ -2,7 +2,6 @@ defmodule Mobilizon.GraphQL.Resolvers.ConfigTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
alias Mobilizon.Actors alias Mobilizon.Actors
alias Mobilizon.Actors.Actor alias Mobilizon.Actors.Actor
use Bamboo.Test
alias Mobilizon.GraphQL.AbsintheHelpers alias Mobilizon.GraphQL.AbsintheHelpers

View File

@ -1,6 +1,5 @@
defmodule Mobilizon.Web.Resolvers.EventTest do defmodule Mobilizon.Web.Resolvers.EventTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
use Bamboo.Test, shared: true
use Oban.Testing, repo: Mobilizon.Storage.Repo use Oban.Testing, repo: Mobilizon.Storage.Repo
import Mobilizon.Factory import Mobilizon.Factory
@ -12,8 +11,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
alias Mobilizon.Users.User alias Mobilizon.Users.User
alias Mobilizon.GraphQL.AbsintheHelpers alias Mobilizon.GraphQL.AbsintheHelpers
import Swoosh.TestAssertions
alias Mobilizon.Web.Email
@event %{ @event %{
description: "some body", description: "some body",
@ -981,12 +979,11 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
%Event{uuid: event_uuid, title: event_title} = %Event{uuid: event_uuid, title: event_title} =
event = insert(:event, organizer_actor: actor) event = insert(:event, organizer_actor: actor)
creator = insert(:participant, event: event, actor: actor, role: :creator) insert(:participant, event: event, actor: actor, role: :creator)
participant_user = insert(:user) participant_user = insert(:user)
participant_actor = insert(:actor, user: participant_user) participant_actor = insert(:actor, user: participant_user)
participant = insert(:participant, event: event, actor: participant_actor, role: :participant)
insert(:participant, event: event, actor: participant_actor, role: :participant)
address = insert(:address) address = insert(:address)
@ -1073,33 +1070,10 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
Oban.drain_queue(queue: :default, with_scheduled: true) Oban.drain_queue(queue: :default, with_scheduled: true)
{:ok, new_event} = Mobilizon.Events.get_event_with_preload(event.id) {:ok, _new_event} = Mobilizon.Events.get_event_with_preload(event.id)
assert_delivered_email( assert_email_sent(to: {actor.name, user.email})
Email.Event.event_updated( assert_email_sent(to: {participant_actor.name, participant_user.email})
user.email,
creator,
actor,
event,
new_event,
MapSet.new([:title, :begins_on, :ends_on, :status, :physical_address]),
"Etc/UTC",
"en"
)
)
assert_delivered_email(
Email.Event.event_updated(
participant_user.email,
participant,
participant_actor,
event,
new_event,
MapSet.new([:title, :begins_on, :ends_on, :status, :physical_address]),
"Etc/UTC",
"en"
)
)
end end
test "update_event/3 updates an event with a new picture", %{ test "update_event/3 updates an event with a new picture", %{

View File

@ -1,6 +1,5 @@
defmodule Mobilizon.GraphQL.Resolvers.MediaTest do defmodule Mobilizon.GraphQL.Resolvers.MediaTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
use Bamboo.Test
import Mobilizon.Factory import Mobilizon.Factory

View File

@ -1,6 +1,5 @@
defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
use Bamboo.Test
use Mobilizon.Tests.Helpers use Mobilizon.Tests.Helpers
alias Mobilizon.Config alias Mobilizon.Config
@ -8,9 +7,9 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
alias Mobilizon.Events.{Event, EventParticipantStats, Participant} alias Mobilizon.Events.{Event, EventParticipantStats, Participant}
alias Mobilizon.GraphQL.AbsintheHelpers alias Mobilizon.GraphQL.AbsintheHelpers
alias Mobilizon.Storage.Page alias Mobilizon.Storage.Page
alias Mobilizon.Web.Email
import Mobilizon.Factory import Mobilizon.Factory
import Swoosh.TestAssertions
@event %{ @event %{
description: "some body", description: "some body",
@ -720,9 +719,9 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
assert json_response(res, 200)["data"]["updateParticipation"]["actor"]["id"] == assert json_response(res, 200)["data"]["updateParticipation"]["actor"]["id"] ==
to_string(actor.id) to_string(actor.id)
participation = Events.get_participant(participation_id) assert %Participant{} = Events.get_participant(participation_id)
assert_delivered_email(Email.Participation.participation_updated(user, participation)) assert_email_sent(to: user.email)
res = res =
conn conn
@ -864,8 +863,8 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
assert json_response(res, 200)["data"]["updateParticipation"]["actor"]["id"] == assert json_response(res, 200)["data"]["updateParticipation"]["actor"]["id"] ==
to_string(actor.id) to_string(actor.id)
participation = Events.get_participant(participation_id) assert %Participant{} = Events.get_participant(participation_id)
assert_delivered_email(Email.Participation.participation_updated(user, participation)) assert_email_sent(to: user.email)
res = res =
conn conn
@ -1112,12 +1111,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
assert %Participant{ assert %Participant{
metadata: %{confirmation_token: confirmation_token}, metadata: %{confirmation_token: confirmation_token},
role: :not_confirmed role: :not_confirmed
} = } = event.id |> Events.list_participants_for_event([]) |> Map.get(:elements) |> hd()
participant =
event.id |> Events.list_participants_for_event([]) |> Map.get(:elements) |> hd()
# hack to avoid preloading event in participant
participant = Map.put(participant, :event, event)
res = res =
conn conn
@ -1128,9 +1122,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
assert hd(res["errors"])["message"] == "You are already a participant of this event" assert hd(res["errors"])["message"] == "You are already a participant of this event"
assert_delivered_email( assert_email_sent(to: @email)
Email.Participation.anonymous_participation_confirmation(@email, participant)
)
res = res =
conn conn
@ -1142,10 +1134,9 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
assert is_nil(res["errors"]) assert is_nil(res["errors"])
assert %Participant{role: :participant} = assert %Participant{role: :participant} =
participant =
event.id |> Events.list_participants_for_event() |> Map.get(:elements) |> hd() event.id |> Events.list_participants_for_event() |> Map.get(:elements) |> hd()
assert_delivered_email(Email.Participation.participation_updated(@email, participant)) assert_email_sent(to: @email)
end end
test "I can participate anonymously and and confirm my participation with bad token", test "I can participate anonymously and and confirm my participation with bad token",
@ -1377,8 +1368,8 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
} }
}} = Events.get_event(event.id) }} = Events.get_event(event.id)
participant = Events.get_participant(participant_id) assert %Participant{} = Events.get_participant(participant_id)
assert_delivered_email(Email.Participation.participation_updated(@email, participant)) assert_email_sent(to: @email)
end end
end end
end end

View File

@ -1,6 +1,5 @@
defmodule Mobilizon.GraphQL.Resolvers.UserTest do defmodule Mobilizon.GraphQL.Resolvers.UserTest do
use Mobilizon.Web.ConnCase use Mobilizon.Web.ConnCase
use Bamboo.Test
use Oban.Testing, repo: Mobilizon.Storage.Repo use Oban.Testing, repo: Mobilizon.Storage.Repo
import Mobilizon.Factory import Mobilizon.Factory
@ -15,6 +14,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
alias Mobilizon.GraphQL.AbsintheHelpers alias Mobilizon.GraphQL.AbsintheHelpers
alias Mobilizon.Web.Email alias Mobilizon.Web.Email
import Swoosh.TestAssertions
@get_user_query """ @get_user_query """
query GetUser($id: ID!) { query GetUser($id: ID!) {
@ -362,7 +362,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
{:ok, user} = Users.get_user_by_email(@user_creation.email) {:ok, user} = Users.get_user_by_email(@user_creation.email)
assert_delivered_email(Email.User.confirmation_email(user, @user_creation.locale)) assert_email_sent(to: user.email)
res = res =
conn conn
@ -705,7 +705,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) |> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert json_response(res, 200)["data"]["resendConfirmationEmail"] == user.email assert json_response(res, 200)["data"]["resendConfirmationEmail"] == user.email
assert_delivered_email(Email.User.confirmation_email(user)) assert_email_sent(to: user.email)
end end
test "test resend_confirmation_email/3 with invalid email resends an validation email", test "test resend_confirmation_email/3 with invalid email resends an validation email",
@ -1279,8 +1279,8 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
assert user.email == @old_email assert user.email == @old_email
assert user.unconfirmed_email == @new_email assert user.unconfirmed_email == @new_email
assert_delivered_email(Email.User.send_email_reset_old_email(user)) assert_email_sent(to: user.email)
assert_delivered_email(Email.User.send_email_reset_new_email(user)) assert_email_sent(to: user.unconfirmed_email)
conn conn
|> AbsintheHelpers.graphql_query( |> AbsintheHelpers.graphql_query(
@ -1329,8 +1329,8 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
assert user.email == @old_email assert user.email == @old_email
assert user.unconfirmed_email == @new_email assert user.unconfirmed_email == @new_email
assert_delivered_email(Email.User.send_email_reset_old_email(user)) assert_email_sent(to: user.email)
assert_delivered_email(Email.User.send_email_reset_new_email(user)) assert_email_sent(to: user.unconfirmed_email)
res = res =
conn conn

View File

@ -7,11 +7,9 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
alias Mobilizon.Config alias Mobilizon.Config
alias Mobilizon.Service.Notifier.Email alias Mobilizon.Service.Notifier.Email
alias Mobilizon.Users.{ActivitySetting, Setting, User} alias Mobilizon.Users.{ActivitySetting, Setting, User}
alias Mobilizon.Web.Email.Activity, as: EmailActivity
use Mobilizon.DataCase use Mobilizon.DataCase
use Bamboo.Test import Swoosh.TestAssertions
import Mobilizon.Factory import Mobilizon.Factory
describe "Returns if the module is loaded" do describe "Returns if the module is loaded" do
@ -35,12 +33,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
assert {:ok, :skipped} == Email.send(user, activity) assert {:ok, :skipped} == Email.send(user, activity)
refute_delivered_email( refute_email_sent()
EmailActivity.direct_activity(
user.email,
[activity]
)
)
end end
test "when the user allows it" do test "when the user allows it" do
@ -57,12 +50,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
assert {:ok, :sent} == Email.send(user, activity) assert {:ok, :sent} == Email.send(user, activity)
assert_delivered_email( assert_email_sent(to: user.email)
EmailActivity.direct_activity(
user.email,
[activity]
)
)
end end
test "if it's been an hour since the last notification" do test "if it's been an hour since the last notification" do
@ -84,12 +72,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
assert {:ok, :sent} == Email.send(user, activity) assert {:ok, :sent} == Email.send(user, activity)
assert_delivered_email( assert_email_sent(to: user.email)
EmailActivity.direct_activity(
user.email,
[activity]
)
)
end end
test "if there's no delay since the last notification" do test "if there's no delay since the last notification" do
@ -111,12 +94,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
assert {:ok, :sent} == Email.send(user, activity) assert {:ok, :sent} == Email.send(user, activity)
assert_delivered_email( assert_email_sent(to: user.email)
EmailActivity.direct_activity(
user.email,
[activity]
)
)
end end
test "not if we already have sent notifications" do test "not if we already have sent notifications" do
@ -138,12 +116,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
assert {:ok, :skipped} == Email.send(user, activity) assert {:ok, :skipped} == Email.send(user, activity)
refute_delivered_email( refute_email_sent()
EmailActivity.direct_activity(
user.email,
[activity]
)
)
end end
end end
@ -155,7 +128,7 @@ defmodule Mobilizon.Service.Notifier.EmailTest do
Email.send_anonymous_activity(@email, activity, locale: "en") Email.send_anonymous_activity(@email, activity, locale: "en")
assert_delivered_email(EmailActivity.anonymous_activity(@email, activity, locale: "en")) assert_email_sent(to: @email)
end end
end end
end end

View File

@ -9,7 +9,6 @@ defmodule Mobilizon.Service.Notifier.PushTest do
alias Mobilizon.Users.{ActivitySetting, Setting, User} alias Mobilizon.Users.{ActivitySetting, Setting, User}
use Mobilizon.DataCase use Mobilizon.DataCase
use Bamboo.Test
import Mobilizon.Factory import Mobilizon.Factory

View File

@ -8,13 +8,14 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
alias Mobilizon.Events.{Event, Participant} alias Mobilizon.Events.{Event, Participant}
alias Mobilizon.Service.Workers.Notification alias Mobilizon.Service.Workers.Notification
alias Mobilizon.Users.User alias Mobilizon.Users.User
alias Mobilizon.Web.Email.Notification, as: NotificationMailer
use Mobilizon.DataCase use Mobilizon.DataCase
use Bamboo.Test
import Swoosh.TestAssertions
import Mobilizon.Factory import Mobilizon.Factory
@email "someone@somewhere.tld"
describe "A before_event_notification job sends an email" do describe "A before_event_notification job sends an email" do
test "if the user is still participating" do test "if the user is still participating" do
%User{id: user_id} = user = insert(:user) %User{id: user_id} = user = insert(:user)
@ -36,12 +37,7 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
args: %{"op" => "before_event_notification", "participant_id" => participant_id} args: %{"op" => "before_event_notification", "participant_id" => participant_id}
}) })
assert_delivered_email( assert_email_sent(to: participant.actor.user.email)
NotificationMailer.before_event_notification(
participant.actor.user.email,
participant
)
)
end end
test "unless the person is no longer participating" do test "unless the person is no longer participating" do
@ -63,30 +59,19 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
args: %{"op" => "before_event_notification", "participant_id" => participant_id} args: %{"op" => "before_event_notification", "participant_id" => participant_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.before_event_notification(
participant.actor.user.email,
participant
)
)
end end
test "unless the event has been cancelled" do test "unless the event has been cancelled" do
%Event{} = event = insert(:event, status: :cancelled) %Event{} = event = insert(:event, status: :cancelled)
%Participant{id: participant_id} = %Participant{id: participant_id} = insert(:participant, role: :participant, event: event)
participant = insert(:participant, role: :participant, event: event)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "before_event_notification", "participant_id" => participant_id} args: %{"op" => "before_event_notification", "participant_id" => participant_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.before_event_notification(
participant.actor.user.email,
participant
)
)
end end
end end
@ -100,19 +85,13 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
user = Map.put(user, :settings, settings) user = Map.put(user, :settings, settings)
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
%Participant{} = participant = insert(:participant, role: :participant, actor: actor) %Participant{} = insert(:participant, role: :participant, actor: actor)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "on_day_notification", "user_id" => user_id} args: %{"op" => "on_day_notification", "user_id" => user_id}
}) })
assert_delivered_email( assert_email_sent(to: user.email)
NotificationMailer.on_day_notification(
user,
[participant],
1
)
)
end end
test "unless the person is no longer participating" do test "unless the person is no longer participating" do
@ -138,13 +117,7 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
args: %{"op" => "on_day_notification", "user_id" => user_id} args: %{"op" => "on_day_notification", "user_id" => user_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.on_day_notification(
user,
[participant],
1
)
)
end end
test "unless the event has been cancelled" do test "unless the event has been cancelled" do
@ -157,24 +130,17 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
%Event{} = event = insert(:event, status: :cancelled) %Event{} = event = insert(:event, status: :cancelled)
%Participant{} = %Participant{} = insert(:participant, role: :participant, event: event, actor: actor)
participant = insert(:participant, role: :participant, event: event, actor: actor)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "on_day_notification", "user_id" => user_id} args: %{"op" => "on_day_notification", "user_id" => user_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.on_day_notification(
user,
[participant],
1
)
)
end end
test "with a lot of events" do test "with a lot of events" do
%User{id: user_id} = user = insert(:user) %User{id: user_id} = user = insert(:user, email: @email)
settings = settings =
insert(:settings, user_id: user_id, notification_on_day: true, timezone: "Europe/Paris") insert(:settings, user_id: user_id, notification_on_day: true, timezone: "Europe/Paris")
@ -182,23 +148,16 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
user = Map.put(user, :settings, settings) user = Map.put(user, :settings, settings)
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
participants = Enum.reduce(0..10, [], fn _i, acc ->
Enum.reduce(0..10, [], fn _i, acc -> %Participant{} = participant = insert(:participant, role: :participant, actor: actor)
%Participant{} = participant = insert(:participant, role: :participant, actor: actor) acc ++ [participant]
acc ++ [participant] end)
end)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "on_day_notification", "user_id" => user_id} args: %{"op" => "on_day_notification", "user_id" => user_id}
}) })
refute_delivered_email( assert_email_sent(to: @email, subject: "11 events planned today")
NotificationMailer.on_day_notification(
user,
participants,
3
)
)
end end
end end
@ -212,19 +171,13 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
user = Map.put(user, :settings, settings) user = Map.put(user, :settings, settings)
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
%Participant{} = participant = insert(:participant, role: :participant, actor: actor) %Participant{} = insert(:participant, role: :participant, actor: actor)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "weekly_notification", "user_id" => user_id} args: %{"op" => "weekly_notification", "user_id" => user_id}
}) })
assert_delivered_email( assert_email_sent(to: user.email)
NotificationMailer.weekly_notification(
user,
[participant],
1
)
)
end end
test "unless the person is no longer participating" do test "unless the person is no longer participating" do
@ -250,13 +203,7 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
args: %{"op" => "weekly_notification", "user_id" => user_id} args: %{"op" => "weekly_notification", "user_id" => user_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.weekly_notification(
user,
[participant],
1
)
)
end end
test "unless the event has been cancelled" do test "unless the event has been cancelled" do
@ -269,24 +216,17 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
%Event{} = event = insert(:event, status: :cancelled) %Event{} = event = insert(:event, status: :cancelled)
%Participant{} = %Participant{} = insert(:participant, role: :participant, event: event, actor: actor)
participant = insert(:participant, role: :participant, event: event, actor: actor)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "weekly_notification", "user_id" => user_id} args: %{"op" => "weekly_notification", "user_id" => user_id}
}) })
refute_delivered_email( refute_email_sent()
NotificationMailer.weekly_notification(
user,
[participant],
1
)
)
end end
test "with a lot of events" do test "with a lot of events" do
%User{id: user_id} = user = insert(:user) %User{id: user_id} = user = insert(:user, email: @email)
settings = settings =
insert(:settings, user_id: user_id, notification_each_week: true, timezone: "Europe/Paris") insert(:settings, user_id: user_id, notification_each_week: true, timezone: "Europe/Paris")
@ -294,23 +234,16 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
user = Map.put(user, :settings, settings) user = Map.put(user, :settings, settings)
%Actor{} = actor = insert(:actor, user: user) %Actor{} = actor = insert(:actor, user: user)
participants = Enum.reduce(0..10, [], fn _i, acc ->
Enum.reduce(0..10, [], fn _i, acc -> %Participant{} = participant = insert(:participant, role: :participant, actor: actor)
%Participant{} = participant = insert(:participant, role: :participant, actor: actor) acc ++ [participant]
acc ++ [participant] end)
end)
Notification.perform(%Oban.Job{ Notification.perform(%Oban.Job{
args: %{"op" => "weekly_notification", "user_id" => user_id} args: %{"op" => "weekly_notification", "user_id" => user_id}
}) })
refute_delivered_email( assert_email_sent(to: @email, subject: "11 events planned this week")
NotificationMailer.weekly_notification(
user,
participants,
3
)
)
end end
end end
@ -318,11 +251,10 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
test "if there are participants to approve" do test "if there are participants to approve" do
%User{id: user_id} = user = insert(:user) %User{id: user_id} = user = insert(:user)
settings = insert(:settings,
insert(:settings, user_id: user_id,
user_id: user_id, timezone: "Europe/Paris"
timezone: "Europe/Paris" )
)
%Event{id: event_id} = event = insert(:event) %Event{id: event_id} = event = insert(:event)
@ -337,13 +269,7 @@ defmodule Mobilizon.Service.Workers.NotificationTest do
} }
}) })
assert_delivered_email( assert_email_sent(to: user.email)
NotificationMailer.pending_participation_notification(
%User{user | settings: settings},
event,
2
)
)
end end
end end
end end