mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FEATURE: secure_email site setting to prevent data going out in email
This commit is contained in:
@ -5,7 +5,7 @@ require_dependency 'age_words'
|
||||
class UserNotifications < ActionMailer::Base
|
||||
include UserNotificationsHelper
|
||||
include ApplicationHelper
|
||||
helper :application
|
||||
helper :application, :email
|
||||
default charset: 'UTF-8'
|
||||
|
||||
include Email::BuildEmailHelper
|
||||
@ -284,10 +284,12 @@ class UserNotifications < ActionMailer::Base
|
||||
|
||||
class UserNotificationRenderer < ActionView::Base
|
||||
include UserNotificationsHelper
|
||||
include EmailHelper
|
||||
end
|
||||
|
||||
def self.get_context_posts(post, topic_user, user)
|
||||
if user.user_option.email_previous_replies == UserOption.previous_replies_type[:never]
|
||||
if (user.user_option.email_previous_replies == UserOption.previous_replies_type[:never]) ||
|
||||
SiteSetting.private_email?
|
||||
return []
|
||||
end
|
||||
|
||||
@ -349,6 +351,7 @@ class UserNotifications < ActionMailer::Base
|
||||
def send_notification_email(opts)
|
||||
post = opts[:post]
|
||||
title = opts[:title]
|
||||
|
||||
allow_reply_by_email = opts[:allow_reply_by_email]
|
||||
use_site_subject = opts[:use_site_subject]
|
||||
add_re_to_subject = opts[:add_re_to_subject] && post.post_number > 1
|
||||
@ -377,6 +380,10 @@ class UserNotifications < ActionMailer::Base
|
||||
show_category_in_subject = nil
|
||||
end
|
||||
|
||||
if SiteSetting.private_email?
|
||||
title = I18n.t("system_messages.private_topic_title", id: post.topic_id)
|
||||
end
|
||||
|
||||
context = ""
|
||||
tu = TopicUser.get(post.topic_id, user)
|
||||
context_posts = self.class.get_context_posts(post, tu, user)
|
||||
@ -418,7 +425,12 @@ class UserNotifications < ActionMailer::Base
|
||||
.count) >= (SiteSetting.max_emails_per_day_per_user-1)
|
||||
|
||||
in_reply_to_post = post.reply_to_post if user.user_option.email_in_reply_to
|
||||
message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "");
|
||||
if SiteSetting.private_email?
|
||||
message = I18n.t('system_messages.contents_hidden')
|
||||
else
|
||||
message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "");
|
||||
end
|
||||
|
||||
|
||||
unless translation_override_exists
|
||||
html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
|
||||
@ -438,7 +450,7 @@ class UserNotifications < ActionMailer::Base
|
||||
topic_title: gsub_emoji_to_unicode(title),
|
||||
topic_title_url_encoded: title ? URI.encode(title) : title,
|
||||
message: message,
|
||||
url: post.url,
|
||||
url: post.url(without_slug: SiteSetting.private_email?),
|
||||
post_id: post.id,
|
||||
topic_id: post.topic_id,
|
||||
context: context,
|
||||
|
Reference in New Issue
Block a user