Send notifications to event organizer when new comment is posted
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -56,7 +56,8 @@ defmodule Mobilizon.Service.Notifier.Email do
|
||||
@always_direct_subjects [
|
||||
:participation_event_comment,
|
||||
:event_comment_mention,
|
||||
:discussion_mention
|
||||
:discussion_mention,
|
||||
:event_new_comment
|
||||
]
|
||||
|
||||
@spec can_send_activity?(Activity.t(), User.t(), Keyword.t()) :: boolean()
|
||||
@@ -96,30 +97,24 @@ defmodule Mobilizon.Service.Notifier.Email do
|
||||
when subject in @always_direct_subjects,
|
||||
do: true
|
||||
|
||||
# First notification EVER!
|
||||
defp match_group_notifications_setting(:one_hour, _, last_notification_sent, _)
|
||||
when is_nil(last_notification_sent),
|
||||
do: true
|
||||
|
||||
# Delay ok since last notification
|
||||
defp match_group_notifications_setting(:one_hour, _, %DateTime{} = last_notification_sent, _) do
|
||||
is_delay_ok_since_last_notification_sent(last_notification_sent)
|
||||
end
|
||||
|
||||
# This is a recap
|
||||
defp match_group_notifications_setting(
|
||||
group_notifications,
|
||||
_group_notifications,
|
||||
_subject,
|
||||
last_notification_sent,
|
||||
_last_notification_sent,
|
||||
options
|
||||
) do
|
||||
cond do
|
||||
# This is a recap
|
||||
Keyword.get(options, :recap, false) != false ->
|
||||
true
|
||||
|
||||
# First notification EVER!
|
||||
group_notifications == :one_hour && is_nil(last_notification_sent) ->
|
||||
true
|
||||
|
||||
# Delay ok since last notification
|
||||
group_notifications == :one_hour &&
|
||||
is_delay_ok_since_last_notification_sent(last_notification_sent) ->
|
||||
true
|
||||
|
||||
# Otherwise, no thanks
|
||||
true ->
|
||||
false
|
||||
end
|
||||
Keyword.get(options, :recap, false) != false
|
||||
end
|
||||
|
||||
@default_behavior %{
|
||||
|
||||
@@ -23,10 +23,13 @@ defmodule Mobilizon.Service.Notifier.Filter do
|
||||
defp enabled?(nil, activity_setting, get_default), do: get_default.(activity_setting)
|
||||
defp enabled?(%ActivitySetting{enabled: enabled}, _activity_setting, _get_default), do: enabled
|
||||
|
||||
# Comment mention
|
||||
# Mention
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :event_comment_mention}),
|
||||
do: "event_comment_mention"
|
||||
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :discussion_mention}),
|
||||
do: "discussion_mention"
|
||||
|
||||
# Participation
|
||||
@spec map_activity_to_activity_setting(Activity.t()) :: String.t() | false
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :participation_event_updated}),
|
||||
@@ -42,6 +45,9 @@ defmodule Mobilizon.Service.Notifier.Filter do
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :event_new_participation}),
|
||||
do: "event_new_participation"
|
||||
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :event_new_comment}),
|
||||
do: "event_new_comment"
|
||||
|
||||
# Event
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :event_created}), do: "event_created"
|
||||
defp map_activity_to_activity_setting(%Activity{type: :event}), do: "event_updated"
|
||||
@@ -60,7 +66,7 @@ defmodule Mobilizon.Service.Notifier.Filter do
|
||||
defp map_activity_to_activity_setting(%Activity{subject: :member_request}),
|
||||
do: "member_request"
|
||||
|
||||
defp map_activity_to_activity_setting(%Activity{type: :member}), do: "member"
|
||||
defp map_activity_to_activity_setting(%Activity{type: :member}), do: "member_updated"
|
||||
|
||||
defp map_activity_to_activity_setting(_), do: false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user