Check against "Auto-Submitted: no" instead
This would be much more accurate. We assume this is an auto-generated email if such header is provided, and the value is not "no". It could also be: "auto-generated", "auto-replied", or other values from extension. It seems that only "no" could mean that this is sent by a human. See: https://tools.ietf.org/html/rfc3834
This commit is contained in:
parent
f097e4dbcd
commit
86e1f41b83
1 changed files with 11 additions and 2 deletions
|
@ -27,8 +27,7 @@ module Gitlab
|
|||
|
||||
mail = build_mail
|
||||
|
||||
raise AutoGeneratedEmailError if
|
||||
mail.header.to_s =~ /auto-(generated|replied)/
|
||||
ignore_auto_submitted!(mail)
|
||||
|
||||
mail_key = extract_mail_key(mail)
|
||||
handler = Handler.for(mail, mail_key)
|
||||
|
@ -91,6 +90,16 @@ module Gitlab
|
|||
break key if key
|
||||
end
|
||||
end
|
||||
|
||||
def ignore_auto_submitted!(mail)
|
||||
# Mail::Header#[] is case-insensitive
|
||||
auto_submitted = mail.header['Auto-Submitted']&.value
|
||||
|
||||
# Mail::Field#value would strip leading and trailing whitespace
|
||||
raise AutoGeneratedEmailError if
|
||||
# See also https://tools.ietf.org/html/rfc3834
|
||||
auto_submitted && auto_submitted != 'no'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue