Allow anonymous participants to have timezone metadata
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -14,15 +14,24 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
alias Mobilizon.Events.{Event, Participant}
|
||||
alias Mobilizon.Storage.Repo
|
||||
alias Mobilizon.Users.{Setting, User}
|
||||
|
||||
alias Mobilizon.Web.Email
|
||||
alias Mobilizon.Web.JsonLD.ObjectView
|
||||
|
||||
@important_changes [:title, :begins_on, :ends_on, :status, :physical_address]
|
||||
|
||||
@spec event_updated(String.t(), Actor.t(), Event.t(), Event.t(), MapSet.t(), String.t()) ::
|
||||
@spec event_updated(
|
||||
Participant.t(),
|
||||
String.t(),
|
||||
Actor.t(),
|
||||
Event.t(),
|
||||
Event.t(),
|
||||
MapSet.t(),
|
||||
String.t()
|
||||
) ::
|
||||
Bamboo.Email.t()
|
||||
def event_updated(
|
||||
email,
|
||||
%Participant{} = participant,
|
||||
%Actor{} = actor,
|
||||
%Event{} = old_event,
|
||||
%Event{} = event,
|
||||
@@ -83,13 +92,14 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
MapSet.t()
|
||||
) :: Bamboo.Email.t()
|
||||
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}},
|
||||
%Event{} = old_event,
|
||||
%Event{} = event,
|
||||
diff
|
||||
) do
|
||||
do_send_notification_for_event_update_to_participant(
|
||||
participant,
|
||||
email,
|
||||
actor,
|
||||
old_event,
|
||||
@@ -101,13 +111,14 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
end
|
||||
|
||||
defp send_notification_for_event_update_to_participant(
|
||||
{%Participant{} = _participant, %Actor{} = actor,
|
||||
{%Participant{} = participant, %Actor{} = actor,
|
||||
%User{locale: locale, email: email} = _user, nil},
|
||||
%Event{} = old_event,
|
||||
%Event{} = event,
|
||||
diff
|
||||
) do
|
||||
do_send_notification_for_event_update_to_participant(
|
||||
participant,
|
||||
email,
|
||||
actor,
|
||||
old_event,
|
||||
@@ -119,7 +130,8 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
end
|
||||
|
||||
defp send_notification_for_event_update_to_participant(
|
||||
{%Participant{metadata: %{email: email}} = _participant, %Actor{} = actor, nil, nil},
|
||||
{%Participant{metadata: %{email: email} = participant_metadata} = participant,
|
||||
%Actor{} = actor, nil, nil},
|
||||
%Event{} = old_event,
|
||||
%Event{} = event,
|
||||
diff
|
||||
@@ -128,17 +140,19 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
locale = Gettext.get_locale()
|
||||
|
||||
do_send_notification_for_event_update_to_participant(
|
||||
participant,
|
||||
email,
|
||||
actor,
|
||||
old_event,
|
||||
event,
|
||||
diff,
|
||||
"Etc/UTC",
|
||||
Map.get(participant_metadata, :timezone, "Etc/UTC"),
|
||||
locale
|
||||
)
|
||||
end
|
||||
|
||||
@spec do_send_notification_for_event_update_to_participant(
|
||||
Participant.t(),
|
||||
String.t(),
|
||||
Actor.t(),
|
||||
Event.t(),
|
||||
@@ -148,6 +162,7 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
String.t()
|
||||
) :: Bamboo.Email.t()
|
||||
defp do_send_notification_for_event_update_to_participant(
|
||||
participant,
|
||||
email,
|
||||
actor,
|
||||
old_event,
|
||||
@@ -157,7 +172,7 @@ defmodule Mobilizon.Web.Email.Event do
|
||||
locale
|
||||
) do
|
||||
email
|
||||
|> Email.Event.event_updated(actor, old_event, event, diff, timezone, locale)
|
||||
|> Email.Event.event_updated(participant, actor, old_event, event, diff, timezone, locale)
|
||||
|> Email.Mailer.send_email_later()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: event, role: :rejected},
|
||||
%Participant{event: event, role: :rejected} = participant,
|
||||
locale
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
@@ -73,13 +73,15 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
|> assign(:subject, subject)
|
||||
|> render(:event_participation_rejected)
|
||||
end
|
||||
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: %Event{join_options: :free} = event, role: :participant},
|
||||
%Participant{event: %Event{join_options: :free} = event, role: :participant} =
|
||||
participant,
|
||||
locale
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
@@ -94,12 +96,13 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:subject, subject)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
|> render(:event_participation_confirmed)
|
||||
end
|
||||
|
||||
def participation_updated(
|
||||
email,
|
||||
%Participant{event: event, role: :participant},
|
||||
%Participant{event: event, role: :participant} = participant,
|
||||
locale
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
Reference in New Issue
Block a user