feat: add links to cancel anonymous participations in emails
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -176,7 +176,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
|
||||
|
||||
case Participations.leave(event, actor, %{local: false, cancellation_token: token}) do
|
||||
{:ok, _activity, %Participant{id: participant_id} = _participant} ->
|
||||
{:ok, %{event: %{id: event_id}, actor: %{id: actor_id}, id: participant_id}}
|
||||
{:ok, %Event{} = event} = Events.get_event_with_preload(event_id)
|
||||
%Actor{} = actor = Actors.get_actor_with_preload!(actor_id)
|
||||
{:ok, %{event: event, actor: actor, id: participant_id}}
|
||||
|
||||
{:error, :is_only_organizer} ->
|
||||
{:error,
|
||||
@@ -202,8 +204,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
|
||||
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id),
|
||||
{:has_event, {:ok, %Event{} = event}} <-
|
||||
{:has_event, Events.get_event_with_preload(event_id)},
|
||||
{:ok, _activity, _participant} <- Participations.leave(event, actor) do
|
||||
{:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}}
|
||||
{:ok, _activity, %Participant{id: participant_id} = _participant} <-
|
||||
Participations.leave(event, actor) do
|
||||
{:ok, %Event{} = event} = Events.get_event_with_preload(event_id)
|
||||
%Actor{} = actor = Actors.get_actor_with_preload!(actor_id)
|
||||
{:ok, %{event: event, actor: actor, id: participant_id}}
|
||||
else
|
||||
{:has_event, _} ->
|
||||
{:error, "Event with this ID #{inspect(event_id)} doesn't exist"}
|
||||
|
||||
@@ -90,8 +90,8 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
|
||||
object :deleted_participant do
|
||||
meta(:authorize, :all)
|
||||
field(:id, :id, description: "The participant ID")
|
||||
field(:event, :deleted_object, description: "The participant's event")
|
||||
field(:actor, :deleted_object, description: "The participant's actor")
|
||||
field(:event, :event, description: "The participant's event")
|
||||
field(:actor, :actor, description: "The participant's actor")
|
||||
end
|
||||
|
||||
object :participant_mutations do
|
||||
|
||||
@@ -26,6 +26,8 @@ defmodule Mobilizon.Web.PageController do
|
||||
defdelegate moderation_report(conn, params), to: PageController, as: :index
|
||||
@spec participation_email_confirmation(Plug.Conn.t(), any) :: Plug.Conn.t()
|
||||
defdelegate participation_email_confirmation(conn, params), to: PageController, as: :index
|
||||
@spec participation_email_cancellation(Plug.Conn.t(), any) :: Plug.Conn.t()
|
||||
defdelegate participation_email_cancellation(conn, params), to: PageController, as: :index
|
||||
@spec user_email_validation(Plug.Conn.t(), any) :: Plug.Conn.t()
|
||||
defdelegate user_email_validation(conn, params), to: PageController, as: :index
|
||||
@spec my_groups(Plug.Conn.t(), any) :: Plug.Conn.t()
|
||||
|
||||
@@ -99,6 +99,7 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
participant: participant,
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
@@ -123,6 +124,7 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
participant: participant,
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
|
||||
@@ -195,6 +195,12 @@ defmodule Mobilizon.Web.Router do
|
||||
|
||||
get("/participation/email/confirm/:token", PageController, :participation_email_confirmation)
|
||||
|
||||
get(
|
||||
"/participation/email/cancel/:uuid/:token",
|
||||
PageController,
|
||||
:participation_email_cancellation
|
||||
)
|
||||
|
||||
get("/validate/email/:token", PageController, :user_email_validation)
|
||||
|
||||
get("/groups/me", PageController, :my_groups)
|
||||
|
||||
@@ -87,14 +87,39 @@
|
||||
style="padding: 20px 30px 40px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"
|
||||
>
|
||||
<p style="margin: 0">
|
||||
<%= ngettext(
|
||||
"Would you wish to cancel your attendance, visit the event page through the link above and click the « Attending » button.",
|
||||
"Would you wish to cancel your attendance to one or several events, visit the event pages through the links above and click the « Attending » button.",
|
||||
1
|
||||
<%= gettext(
|
||||
"If you wish to cancel your participation, simply click on the link below."
|
||||
) %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#ffffff" align="left">
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td align="center" style="border-radius: 3px;">
|
||||
<a
|
||||
href={
|
||||
~p"/participation/email/cancel/#{@event.uuid}/#{@participant.metadata.cancellation_token}"
|
||||
|> url()
|
||||
|> URI.decode()
|
||||
}
|
||||
target="_blank"
|
||||
style="font-size: 20px; font-family: 'Roboto', Helvetica, Arial, sans-serif; color: #3C376E; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #3C376E; display: inline-block;"
|
||||
>
|
||||
<%= gettext("Cancel my attendance") %>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
bgcolor="#ffffff"
|
||||
|
||||
@@ -88,19 +88,62 @@
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
bgcolor="#ffffff"
|
||||
align="left"
|
||||
style="padding: 20px 30px 40px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"
|
||||
>
|
||||
<p style="margin: 0">
|
||||
<%= gettext(
|
||||
"Would you wish to update or cancel your attendance, simply access the event page through the link above and click on the Attending button."
|
||||
) %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<%= if @participant.metadata.cancellation_token do %>
|
||||
<tr>
|
||||
<td
|
||||
bgcolor="#ffffff"
|
||||
align="left"
|
||||
style="padding: 20px 30px 40px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"
|
||||
>
|
||||
<p style="margin: 0">
|
||||
<%= gettext(
|
||||
"If you wish to cancel your participation, simply click on the link below."
|
||||
) %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#ffffff" align="left">
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td align="center" style="border-radius: 3px;">
|
||||
<a
|
||||
href={
|
||||
~p"/participation/email/cancel/#{@event.uuid}/#{@participant.metadata.cancellation_token}"
|
||||
|> url()
|
||||
|> URI.decode()
|
||||
}
|
||||
target="_blank"
|
||||
style="font-size: 20px; font-family: 'Roboto', Helvetica, Arial, sans-serif; color: #3C376E; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #3C376E; display: inline-block;"
|
||||
>
|
||||
<%= gettext("Cancel my attendance") %>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<% else %>
|
||||
<tr>
|
||||
<td
|
||||
bgcolor="#ffffff"
|
||||
align="left"
|
||||
style="padding: 20px 30px 40px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"
|
||||
>
|
||||
<p style="margin: 0">
|
||||
<%= gettext(
|
||||
"Would you wish to update or cancel your attendance, simply access the event page through the link above and click on the Attending button."
|
||||
) %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user