From e7c6f7413c8f1aecdbc68781c8eb9cf1ddcd8543 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 12 Mar 2018 11:10:46 +0100 Subject: [PATCH] Allow message id as selectable field in postmaster filter. --- .../_ui_element/postmaster_match.coffee | 4 ++ test/unit/email_postmaster_test.rb | 44 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee b/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee index 8db4bd490..1002dda11 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee @@ -95,6 +95,10 @@ class App.UiElement.postmaster_match value: 'mailing-list' name: 'Mailing-List' }, + { + value: 'message-id' + name: 'Message-Id' + }, { value: 'auto-submitted' name: 'Auto-Submitted' diff --git a/test/unit/email_postmaster_test.rb b/test/unit/email_postmaster_test.rb index 877c8b0b3..00336e314 100644 --- a/test/unit/email_postmaster_test.rb +++ b/test/unit/email_postmaster_test.rb @@ -368,8 +368,49 @@ Some Text' assert_equal('Customer', article.sender.name) assert_equal('email', article.type.name) assert_equal(false, article.internal) + end - PostmasterFilter.destroy_all + test 'process with postmaster filter - message-id as match condition' do + PostmasterFilter.create!( + name: 'used - message-id', + match: { + 'message-id': { + operator: 'contains', + value: '@sombody.domain>', + }, + }, + perform: { + 'X-Zammad-Ticket-priority_id' => { + value: '1', + }, + 'x-Zammad-Article-Internal' => { + value: true, + }, + }, + channel: 'email', + active: true, + created_by_id: 1, + updated_by_id: 1, + ) + + data = 'From: Some Body +To: Bob +Cc: any@example.com +Subject: *me* +Message-Id: <1520781034.17887@sombody.domain> + +Some Text' + + parser = Channel::EmailParser.new + ticket, article, user = parser.process({}, data) + + assert_equal('Users', ticket.group.name) + assert_equal('1 low', ticket.priority.name) + assert_equal('*me*', ticket.title) + + assert_equal('Customer', article.sender.name) + assert_equal('email', article.type.name) + assert_equal(true, article.internal) end test 'process with postmaster filter' do @@ -918,7 +959,6 @@ Some Text' assert_equal('Customer', article.sender.name) assert_equal('email', article.type.name) assert_equal(false, article.internal) - end end