Notifications on event update
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -11,7 +11,8 @@ defmodule MobilizonWeb.Email do
|
||||
def base_email(args) do
|
||||
instance = Config.instance_config()
|
||||
|
||||
new_email(args)
|
||||
args
|
||||
|> new_email()
|
||||
|> from(Config.instance_email_from())
|
||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||
|> assign(:instance, instance)
|
||||
|
||||
43
lib/mobilizon_web/email/event.ex
Normal file
43
lib/mobilizon_web/email/event.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule MobilizonWeb.Email.Event do
|
||||
@moduledoc """
|
||||
Handles emails sent about events.
|
||||
"""
|
||||
|
||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
||||
|
||||
import Bamboo.Phoenix
|
||||
|
||||
import MobilizonWeb.Gettext
|
||||
|
||||
alias Mobilizon.Events.Event
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Users.User
|
||||
alias MobilizonWeb.Email
|
||||
|
||||
@spec event_updated(User.t(), Actor.t(), Event.t(), Event.t(), list(), String.t()) ::
|
||||
Bamboo.Email.t()
|
||||
def event_updated(
|
||||
%User{} = user,
|
||||
%Actor{} = actor,
|
||||
%Event{} = old_event,
|
||||
%Event{} = event,
|
||||
changes,
|
||||
locale \\ "en"
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
subject =
|
||||
gettext(
|
||||
"Event %{title} has been updated",
|
||||
title: old_event.title
|
||||
)
|
||||
|
||||
Email.base_email(to: {Actor.display_name(actor), user.email}, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:old_event, old_event)
|
||||
|> assign(:changes, changes)
|
||||
|> assign(:subject, subject)
|
||||
|> render(:event_updated)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user