Moved postmaster filter options to config.

This commit is contained in:
Martin Edenhofer 2016-04-12 09:25:20 +02:00
parent 6f56399af2
commit 1fd36cfc6a
3 changed files with 120 additions and 14 deletions

View file

@ -346,16 +346,10 @@ retrns
mail = parse(msg)
# run postmaster pre filter
filters = {
'0010' => Channel::Filter::Trusted,
'0020' => Channel::Filter::AutoResponseCheck,
'0030' => Channel::Filter::OutOfOfficeCheck,
'0100' => Channel::Filter::FollowUpCheck,
'0900' => Channel::Filter::BounceCheck,
'1000' => Channel::Filter::Database,
filters = {}
Setting.where(area: 'Postmaster::PreFilter').each {|setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
}
# filter(channel, mail)
filters.each {|_prio, backend|
begin
backend.run(channel, mail)
@ -511,11 +505,9 @@ retrns
Observer::Ticket::Notification.transaction
# run postmaster post filter
filters = {
# '0010' => Channel::Filter::Trusted,
Setting.where(area: 'Postmaster::PostFilter').each {|setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
}
# filter( channel, mail )
filters.each {|_prio, backend|
begin
backend.run(channel, mail, ticket, article, user)

View file

@ -0,0 +1,59 @@
class AddConfigPostmasterFilter < ActiveRecord::Migration
def up
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0010_postmaster_filter_trusted',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to remove X-Zammad-Headers from not trusted sources.',
options: {},
state: 'Channel::Filter::Trusted',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0020_postmaster_filter_auto_response_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify auto responses to prevent auto replies from Zammad.',
options: {},
state: 'Channel::Filter::AutoResponseCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0030_postmaster_filter_out_of_office_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify out of office emails for follow up detection and keeping current ticket state.',
options: {},
state: 'Channel::Filter::OutOfOfficeCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0100_postmaster_filter_follow_up_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify follow ups (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0900_postmaster_filter_bounce_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify postmaster bounced - to handle it as follow up of origin ticket.',
options: {},
state: 'Channel::Filter::BounceCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '1000_postmaster_filter_database_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter for filters managed via admin interface.',
options: {},
state: 'Channel::Filter::Database',
frontend: false
)
end
end

View file

@ -1516,6 +1516,61 @@ Setting.create_if_not_exists(
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0010_postmaster_filter_trusted',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to remove X-Zammad-Headers from not trusted sources.',
options: {},
state: 'Channel::Filter::Trusted',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0020_postmaster_filter_auto_response_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify auto responses to prevent auto replies from Zammad.',
options: {},
state: 'Channel::Filter::AutoResponseCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0030_postmaster_filter_out_of_office_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify out of office emails for follow up detection and keeping current ticket state.',
options: {},
state: 'Channel::Filter::OutOfOfficeCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0100_postmaster_filter_follow_up_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify follow ups (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '0900_postmaster_filter_bounce_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to identify postmaster bounced - to handle it as follow up of origin ticket.',
options: {},
state: 'Channel::Filter::BounceCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Define postmaster filter.',
name: '1000_postmaster_filter_database_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter for filters managed via admin interface.',
options: {},
state: 'Channel::Filter::Database',
frontend: false
)
signature = Signature.create_if_not_exists(
id: 1,
name: 'default',
@ -1740,7 +1795,7 @@ Overview.create_if_not_exists(
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
pre_condition: 'not_set',
},
},
order: {