enqueue spam/dmarc failing emails instead of hiding (#8674)

* enqueue spam/dmarc failing emails instead of hiding

* add translations for dmarc/spam enqueued reasons

* unescape quote

* if email_in_authserv_id is blank return gray for all emails
This commit is contained in:
Leo McArdle
2020-01-21 16:12:00 +00:00
committed by Robin Ward
parent 411512c0e3
commit 8883cca373
7 changed files with 142 additions and 70 deletions

View File

@ -160,7 +160,6 @@ module Email
create_reply(user: user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
post: post,
topic: post.topic,
skip_validations: user.staged?,
@ -170,7 +169,7 @@ module Email
destinations.each do |destination|
begin
return process_destination(destination, user, body, elided, hidden_reason_id)
return process_destination(destination, user, body, elided)
rescue => e
first_exception ||= e
end
@ -195,17 +194,6 @@ module Email
end
end
def hidden_reason_id
@hidden_reason_id ||=
if is_spam?
Post.hidden_reasons[:email_spam_header_found]
elsif !sent_to_mailinglist_mirror? && auth_res_action == :hide
Post.hidden_reasons[:email_authentication_result_header]
else
nil
end
end
def log_and_validate_user(user)
@incoming_email.update_columns(user_id: user.id)
@ -242,7 +230,6 @@ module Email
create_reply(user: @from_user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
post: post,
topic: topic,
skip_validations: true,
@ -667,7 +654,7 @@ module Email
nil
end
def process_destination(destination, user, body, elided, hidden_reason_id)
def process_destination(destination, user, body, elided)
return if SiteSetting.forwarded_emails_behaviour != "hide" &&
has_been_forwarded? &&
process_forwarded_email(destination, user)
@ -679,7 +666,7 @@ module Email
user ||= stage_from_user
group = destination[:obj]
create_group_post(group, user, body, elided, hidden_reason_id)
create_group_post(group, user, body, elided)
when :category
category = destination[:obj]
@ -693,7 +680,6 @@ module Email
create_topic(user: user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
title: subject,
category: category.id,
skip_validations: user.staged?)
@ -713,7 +699,6 @@ module Email
create_reply(user: user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
post: post,
topic: post&.topic,
skip_validations: user.staged?,
@ -721,7 +706,7 @@ module Email
end
end
def create_group_post(group, user, body, elided, hidden_reason_id)
def create_group_post(group, user, body, elided)
message_ids = Email::Receiver.extract_reply_message_ids(@mail, max_message_id_count: 5)
post_ids = []
@ -739,7 +724,6 @@ module Email
create_reply(user: user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
post: post,
topic: post.topic,
skip_validations: true)
@ -749,7 +733,6 @@ module Email
create_topic(user: user,
raw: body,
elided: elided,
hidden_reason_id: hidden_reason_id,
title: subject,
archetype: Archetype.private_message,
target_group_names: [group.name],
@ -1135,6 +1118,10 @@ module Email
if sent_to_mailinglist_mirror?
options[:skip_validations] = true
options[:skip_guardian] = true
else
options[:email_spam] = is_spam?
options[:first_post_checks] = true if is_spam?
options[:email_auth_res_action] = auth_res_action
end
user = options.delete(:user)