summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/mail_handler.rb19
-rw-r--r--test/unit/mail_handler_test.rb18
2 files changed, 26 insertions, 11 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index e0c12f1a0..e920dbd5f 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -42,6 +42,12 @@ class MailHandler < ActionMailer::Base
super email
end
+ cattr_accessor :ignored_emails_headers
+ @@ignored_emails_headers = {
+ 'X-Auto-Response-Suppress' => 'OOF',
+ 'Auto-Submitted' => 'auto-replied'
+ }
+
# Processes incoming emails
# Returns the created object (eg. an issue, a message) or false
def receive(email)
@@ -54,12 +60,15 @@ class MailHandler < ActionMailer::Base
end
return false
end
- # Ignore out-of-office emails
- if email.header_string("X-Auto-Response-Suppress") == 'OOF'
- if logger && logger.info
- logger.info "MailHandler: ignoring out-of-office email"
+ # Ignore auto generated emails
+ self.class.ignored_emails_headers.each do |key, ignored_value|
+ value = email.header_string(key)
+ if value && value.to_s.downcase == ignored_value.downcase
+ if logger && logger.info
+ logger.info "MailHandler: ignoring email with #{key}:#{value} header"
+ end
+ return false
end
- return false
end
@user = User.find_by_mail(sender_email) if sender_email.present?
if @user && !@user.active?
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 645a6f15f..73a93088d 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -359,12 +359,18 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
- def test_should_ignore_oof_emails
- raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
- raw = "X-Auto-Response-Suppress: OOF\n" + raw
-
- assert_no_difference 'Issue.count' do
- assert_equal false, MailHandler.receive(raw)
+ def test_should_ignore_auto_replied_emails
+ [
+ "X-Auto-Response-Suppress: OOF",
+ "Auto-Submitted: auto-replied",
+ "Auto-Submitted: Auto-Replied"
+ ].each do |header|
+ raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
+ raw = header + "\n" + raw
+
+ assert_no_difference 'Issue.count' do
+ assert_equal false, MailHandler.receive(raw), "email with #{header} header was not ignored"
+ end
end
end
30'>backport/40394/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/l10n/af/media.po
blob: 6ef8fb90646ea65388c89ad9756f7d341b2fc422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66