Use correct locale for participation emails
For anonymous participations we now use a locale parameter in metadata Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -69,7 +69,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
|
||||
Config.anonymous_participation_email_confirmation_required?() do
|
||||
args
|
||||
|> Map.get(:email)
|
||||
|> Email.Participation.anonymous_participation_confirmation(participant)
|
||||
|> Email.Participation.anonymous_participation_confirmation(
|
||||
participant,
|
||||
Map.get(args, :locale, "en")
|
||||
)
|
||||
|> Email.Mailer.deliver_later()
|
||||
end
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
|
||||
)
|
||||
|
||||
field(:message, :string, description: "The eventual message the participant left")
|
||||
field(:locale, :string, description: "The participant's locale")
|
||||
end
|
||||
|
||||
object :paginated_participant_list do
|
||||
@@ -74,6 +75,7 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
|
||||
arg(:actor_id, non_null(:id))
|
||||
arg(:email, :string)
|
||||
arg(:message, :string)
|
||||
arg(:locale, :string)
|
||||
|
||||
resolve(&Participant.actor_join_event/3)
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ defmodule Mobilizon.Events.Participant do
|
||||
|
||||
@required_attrs [:url, :role, :event_id, :actor_id]
|
||||
@attrs @required_attrs
|
||||
@metadata_attrs [:email, :confirmation_token, :cancellation_token, :message]
|
||||
@metadata_attrs [:email, :confirmation_token, :cancellation_token, :message, :locale]
|
||||
|
||||
@timestamps_opts [type: :utc_datetime]
|
||||
|
||||
@@ -38,6 +38,7 @@ defmodule Mobilizon.Events.Participant do
|
||||
field(:confirmation_token, :string)
|
||||
field(:cancellation_token, :string)
|
||||
field(:message, :string)
|
||||
field(:locale, :string)
|
||||
end
|
||||
|
||||
belongs_to(:event, Event, primary_key: true)
|
||||
|
||||
@@ -21,10 +21,11 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
%Participant{actor: %Actor{user_id: nil, id: actor_id} = _actor} = participation
|
||||
) do
|
||||
if actor_id == Config.anonymous_actor_id() do
|
||||
%{email: email} = Map.get(participation, :metadata)
|
||||
%{email: email, locale: locale} = Map.get(participation, :metadata)
|
||||
locale = locale || "en"
|
||||
|
||||
email
|
||||
|> participation_updated(participation)
|
||||
|> participation_updated(participation, locale)
|
||||
|> Email.Mailer.deliver_later()
|
||||
end
|
||||
|
||||
@@ -37,9 +38,9 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
def send_emails_to_local_user(
|
||||
%Participant{actor: %Actor{user_id: user_id} = _actor} = participation
|
||||
) do
|
||||
with %User{} = user <- Users.get_user!(user_id) do
|
||||
with %User{locale: locale} = user <- Users.get_user!(user_id) do
|
||||
user
|
||||
|> participation_updated(participation)
|
||||
|> participation_updated(participation, locale)
|
||||
|> Email.Mailer.deliver_later()
|
||||
|
||||
:ok
|
||||
|
||||
Reference in New Issue
Block a user