From 72ecb80dc755422182753ab8d976fd8c4ac07f57 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 9 Apr 2012 06:27:07 +0000 Subject: [PATCH] Merged r9358 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9376 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mail_handler.rb | 7 +++++++ test/unit/mail_handler_test.rb | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 2d50a8057..e0c12f1a0 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -54,6 +54,13 @@ 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" + end + return false + end @user = User.find_by_mail(sender_email) if sender_email.present? if @user && !@user.active? if logger && logger.info diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 9230f4b0f..645a6f15f 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -359,6 +359,15 @@ 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) + end + end + def test_add_issue_should_send_email_notification Setting.notified_events = ['issue_added'] ActionMailer::Base.deliveries.clear -- 2.39.5