Send notifications to event organizer when new comment is posted

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-06-27 11:21:34 +02:00
parent 93297931bb
commit 3ed25bab81
9 changed files with 161 additions and 64 deletions

View File

@@ -45,6 +45,35 @@ defmodule Mobilizon.Service.Activity.Renderer.Comment do
),
url: event_url(activity)
}
:event_new_comment ->
if activity.subject_params["comment_reply_to"] do
%{
body:
dgettext(
"activity",
"%{profile} has posted a new reply under your event %{event}.",
%{
profile: profile,
event: event_title(activity)
}
),
url: event_comment_url(activity)
}
else
%{
body:
dgettext(
"activity",
"%{profile} has posted a new comment under your event %{event}.",
%{
profile: profile,
event: event_title(activity)
}
),
url: event_comment_url(activity)
}
end
end
end
@@ -56,6 +85,18 @@ defmodule Mobilizon.Service.Activity.Renderer.Comment do
)
end
defp event_comment_url(activity) do
"#{event_url(activity)}#comment-#{comment_uuid(activity)}"
end
defp comment_uuid(activity) do
if activity.subject_params["comment_reply_to"] do
"#{activity.subject_params["reply_to_comment_uuid"]}-#{activity.subject_params["comment_uuid"]}"
else
activity.subject_params["comment_uuid"]
end
end
defp profile(activity), do: Actor.display_name_and_username(activity.author)
defp event_title(activity), do: activity.subject_params["event_title"]
end