mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: don't send email when the post was deleted
This commit is contained in:
@ -87,6 +87,10 @@ module Email
|
||||
|
||||
if topic_id.present? && post_id.present?
|
||||
post = Post.find_by(id: post_id, topic_id: topic_id)
|
||||
|
||||
# guards against deleted posts
|
||||
return skip(SkippedEmailLog.reason_types[:sender_post_deleted]) unless post
|
||||
|
||||
topic = post.topic
|
||||
first_post = topic.ordered_posts.first
|
||||
|
||||
@ -124,7 +128,7 @@ module Email
|
||||
end
|
||||
|
||||
# https://www.ietf.org/rfc/rfc2919.txt
|
||||
if topic && topic.category && !topic.category.uncategorized?
|
||||
if topic&.category && !topic.category.uncategorized?
|
||||
list_id = "#{SiteSetting.title} | #{topic.category.name} <#{topic.category.name.downcase.tr(' ', '-')}.#{host}>"
|
||||
|
||||
# subcategory case
|
||||
@ -166,8 +170,8 @@ module Email
|
||||
email_log.post_id = post_id if post_id.present?
|
||||
|
||||
# Remove headers we don't need anymore
|
||||
@message.header['X-Discourse-Topic-Id'] = nil if topic_id.present?
|
||||
@message.header['X-Discourse-Post-Id'] = nil if post_id.present?
|
||||
@message.header['X-Discourse-Topic-Id'] = nil if topic_id.present?
|
||||
@message.header['X-Discourse-Post-Id'] = nil if post_id.present?
|
||||
|
||||
if reply_key.present?
|
||||
@message.header[Email::MessageBuilder::ALLOW_REPLY_BY_EMAIL_HEADER] = nil
|
||||
@ -199,7 +203,6 @@ module Email
|
||||
return skip(SkippedEmailLog.reason_types[:custom], custom_reason: e.message)
|
||||
end
|
||||
|
||||
# Save and return the email log
|
||||
email_log.save!
|
||||
email_log
|
||||
end
|
||||
|
Reference in New Issue
Block a user