Fixes #3150 - Make channels trusted.
This commit is contained in:
parent
ff5f175640
commit
1e8616151c
2 changed files with 45 additions and 1 deletions
|
@ -6,7 +6,7 @@ module Channel::Filter::Trusted
|
||||||
def self.run(channel, mail)
|
def self.run(channel, mail)
|
||||||
|
|
||||||
# check if trust x-headers
|
# check if trust x-headers
|
||||||
if !channel[:trusted]
|
if !trusted(channel)
|
||||||
mail.each_key do |key|
|
mail.each_key do |key|
|
||||||
next if !key.match?(/^x-zammad/i)
|
next if !key.match?(/^x-zammad/i)
|
||||||
|
|
||||||
|
@ -26,4 +26,11 @@ module Channel::Filter::Trusted
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.trusted(channel)
|
||||||
|
return true if channel[:trusted]
|
||||||
|
return true if channel.instance_of?(Channel) && channel.options[:inbound][:trusted]
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,6 +164,43 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when email contains x-headers' do
|
||||||
|
let(:raw_mail) { <<~RAW.chomp }
|
||||||
|
From: foo@bar.com
|
||||||
|
To: baz@qux.net
|
||||||
|
Subject: Foo
|
||||||
|
X-Zammad-Ticket-priority: 3 high
|
||||||
|
|
||||||
|
Lorem ipsum dolor
|
||||||
|
RAW
|
||||||
|
|
||||||
|
context 'when channel is not trusted' do
|
||||||
|
let(:channel) { create(:channel, options: { inbound: { trusted: false } }) }
|
||||||
|
|
||||||
|
it 'does not change the priority of the ticket (no channel)' do
|
||||||
|
described_class.new.process({}, raw_mail)
|
||||||
|
|
||||||
|
expect(Ticket.last.priority.name).to eq('2 normal')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not change the priority of the ticket (untrusted)' do
|
||||||
|
described_class.new.process(channel, raw_mail)
|
||||||
|
|
||||||
|
expect(Ticket.last.priority.name).to eq('2 normal')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when channel is trusted' do
|
||||||
|
let(:channel) { create(:channel, options: { inbound: { trusted: true } }) }
|
||||||
|
|
||||||
|
it 'does not change the priority of the ticket' do
|
||||||
|
described_class.new.process(channel, raw_mail)
|
||||||
|
|
||||||
|
expect(Ticket.last.priority.name).to eq('3 high')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'associating emails to existing tickets' do
|
describe 'associating emails to existing tickets' do
|
||||||
|
|
Loading…
Reference in a new issue