This commit is contained in:
parent
d684ffa7ba
commit
a4b82a6634
4 changed files with 33 additions and 0 deletions
|
@ -59,6 +59,10 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
|
||||||
sender = User.find(record.created_by_id)
|
sender = User.find(record.created_by_id)
|
||||||
realname = "#{sender.firstname} #{sender.lastname} #{separator} #{email_address.realname}"
|
realname = "#{sender.firstname} #{sender.lastname} #{separator} #{email_address.realname}"
|
||||||
record.from = Channel::EmailBuild.recipient_line(realname, email_address.email)
|
record.from = Channel::EmailBuild.recipient_line(realname, email_address.email)
|
||||||
|
elsif Setting.get('ticket_define_email_from') == 'AgentName'
|
||||||
|
sender = User.find(record.created_by_id)
|
||||||
|
realname = "#{sender.firstname} #{sender.lastname}"
|
||||||
|
record.from = Channel::EmailBuild.recipient_line(realname, email_address.email)
|
||||||
else
|
else
|
||||||
record.from = Channel::EmailBuild.recipient_line(email_address.realname, email_address.email)
|
record.from = Channel::EmailBuild.recipient_line(email_address.realname, email_address.email)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class SettingAddSenderFormatAgentName < ActiveRecord::Migration[5.1]
|
||||||
|
def up
|
||||||
|
# return if it's a new setup
|
||||||
|
return if !Setting.exists?(name: 'system_init_done')
|
||||||
|
|
||||||
|
setting = Setting.find_by(name: 'ticket_define_email_from')
|
||||||
|
return if !setting
|
||||||
|
|
||||||
|
setting.options[:form][0][:options][:AgentName] = 'Agent Name'
|
||||||
|
setting.save!
|
||||||
|
end
|
||||||
|
end
|
|
@ -2524,6 +2524,7 @@ Setting.create_if_not_exists(
|
||||||
options: {
|
options: {
|
||||||
SystemAddressName: 'System Address Display Name',
|
SystemAddressName: 'System Address Display Name',
|
||||||
AgentNameSystemAddressName: 'Agent Name + FromSeparator + System Address Display Name',
|
AgentNameSystemAddressName: 'Agent Name + FromSeparator + System Address Display Name',
|
||||||
|
AgentName: 'Agent Name',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -27,6 +27,22 @@ RSpec.describe Ticket::Article, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Setting of ticket_define_email_from' do
|
||||||
|
subject(:article) do
|
||||||
|
create(:ticket_article, sender_name: 'Agent', type_name: 'email')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when AgentName' do
|
||||||
|
before do
|
||||||
|
Setting.set('ticket_define_email_from', 'AgentName')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets the from based on the setting' do
|
||||||
|
expect(article.reload.from).to eq("\"#{article.created_by.firstname} #{article.created_by.lastname}\" <#{article.ticket.group.email_address.email}>")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Setting of ticket.create_article_{sender,type}' do
|
describe 'Setting of ticket.create_article_{sender,type}' do
|
||||||
let!(:ticket) { create(:ticket) }
|
let!(:ticket) { create(:ticket) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue