mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: do not send notification emails to users who are included in the To and CC header of an incoming email
This commit is contained in:
@@ -392,13 +392,20 @@ class PostAlerter
|
||||
notification_data[:group_name] = group.name
|
||||
end
|
||||
|
||||
if original_post.via_email && (incoming_email = original_post.incoming_email)
|
||||
skip_send_email = contains_email_address?(incoming_email.to_addresses, user) ||
|
||||
contains_email_address?(incoming_email.cc_addresses, user)
|
||||
else
|
||||
skip_send_email = opts[:skip_send_email]
|
||||
end
|
||||
|
||||
# Create the notification
|
||||
user.notifications.create(notification_type: type,
|
||||
topic_id: post.topic_id,
|
||||
post_number: post.post_number,
|
||||
post_action_id: opts[:post_action_id],
|
||||
data: notification_data.to_json,
|
||||
skip_send_email: opts[:skip_send_email])
|
||||
skip_send_email: skip_send_email)
|
||||
|
||||
if !existing_notification && NOTIFIABLE_TYPES.include?(type) && !user.suspended?
|
||||
# we may have an invalid post somehow, dont blow up
|
||||
@@ -422,6 +429,11 @@ class PostAlerter
|
||||
|
||||
end
|
||||
|
||||
def contains_email_address?(addresses, user)
|
||||
return false if addresses.blank?
|
||||
addresses.split(";").include?(user.email)
|
||||
end
|
||||
|
||||
def push_notification(user, payload)
|
||||
if SiteSetting.allow_user_api_key_scopes.split("|").include?("push") && SiteSetting.allowed_user_api_push_urls.present?
|
||||
clients = user.user_api_keys
|
||||
|
||||
Reference in New Issue
Block a user