Added check if sender is system address (show sender as agent in ticket zoom).
This commit is contained in:
parent
0b244d00cb
commit
19dc568355
1 changed files with 32 additions and 0 deletions
32
app/models/channel/filter/sender_is_system_address.rb
Normal file
32
app/models/channel/filter/sender_is_system_address.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
module Channel::Filter::SenderIsSystemAddress
|
||||||
|
|
||||||
|
def self.run(_channel, mail)
|
||||||
|
|
||||||
|
# if attributes already set by header
|
||||||
|
return if mail[ 'x-zammad-ticket-create-article-sender'.to_sym ]
|
||||||
|
return if mail[ 'x-zammad-article-sender'.to_sym ]
|
||||||
|
|
||||||
|
# check if sender addesss is system
|
||||||
|
form = 'raw-from'.to_sym
|
||||||
|
return if !mail[form]
|
||||||
|
return if !mail[:to]
|
||||||
|
|
||||||
|
# in case, set sender
|
||||||
|
begin
|
||||||
|
return if !mail[form].addrs
|
||||||
|
items = mail[form].addrs
|
||||||
|
items.each { |item|
|
||||||
|
next if !EmailAddress.find_by(email: item.address.downcase)
|
||||||
|
mail[ 'x-zammad-ticket-create-article-sender'.to_sym ] = 'Agent'
|
||||||
|
mail[ 'x-zammad-article-sender'.to_sym ] = 'Agent'
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error 'ERROR: SenderIsSystemAddress: ' + e.inspect
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue