Improved reply to / recipient tests (in case agent is sending to system).
This commit is contained in:
parent
0016cb21a5
commit
fe8fba8cb9
2 changed files with 54 additions and 8 deletions
|
@ -952,18 +952,25 @@ class App.Utils
|
|||
article_created_by_email = article_created_by.email.toLowerCase()
|
||||
|
||||
# check if article sender is local
|
||||
senderIsLocal = false
|
||||
if !_.isEmpty(article.from)
|
||||
senderIsLocal = false
|
||||
senders = emailAddresses.parseAddressList(article.from)
|
||||
if senders && senders[0] && senders[0].address
|
||||
senderIsLocal = isLocalAddress(senders[0].address)
|
||||
|
||||
# check if article recipient is local
|
||||
recipientIsLocal = false
|
||||
if !_.isEmpty(article.to)
|
||||
recipients = emailAddresses.parseAddressList(article.to)
|
||||
if recipients && recipients[0] && recipients[0].address
|
||||
recipientIsLocal = isLocalAddress(recipients[0].address)
|
||||
|
||||
# sender is local
|
||||
if senderIsLocal
|
||||
articleNew.to = article.to
|
||||
|
||||
# sender is agent from is different (sender was system)
|
||||
else if article.sender.name is 'Agent' && article_created_by_email && article.from && !article.from.match(article_created_by_email)
|
||||
# sender is agent - sent via system
|
||||
else if article.sender.name is 'Agent' && article_created_by_email && article.from && article.from.toString().toLowerCase().match(article_created_by_email) && !recipientIsLocal
|
||||
articleNew.to = article.to
|
||||
|
||||
# sender was regular customer
|
||||
|
|
|
@ -1984,11 +1984,11 @@ test('check getRecipientArticle format', function() {
|
|||
sender: {
|
||||
name: 'Agent',
|
||||
},
|
||||
from: 'zammad@example.com',
|
||||
from: 'customer2@example.com',
|
||||
to: 'customer@example.com',
|
||||
}
|
||||
result = {
|
||||
to: 'customer@example.com',
|
||||
to: 'customer2@example.com',
|
||||
cc: '',
|
||||
body: '',
|
||||
in_reply_to: 'message_id7',
|
||||
|
@ -2024,7 +2024,7 @@ test('check getRecipientArticle format', function() {
|
|||
to: 'customer@example.com',
|
||||
}
|
||||
result = {
|
||||
to: 'agent@example.com',
|
||||
to: 'customer@example.com',
|
||||
cc: '',
|
||||
body: '',
|
||||
in_reply_to: 'message_id8',
|
||||
|
@ -2295,7 +2295,7 @@ test('check getRecipientArticle format', function() {
|
|||
cc: '',
|
||||
}
|
||||
result = {
|
||||
to: 'customer@example.com, customer1@example.com, customer2@example.com',
|
||||
to: 'customer1@example.com, customer2@example.com, customer@example.com',
|
||||
cc: '',
|
||||
body: '',
|
||||
in_reply_to: 'message_id15',
|
||||
|
@ -2334,7 +2334,7 @@ test('check getRecipientArticle format', function() {
|
|||
cc: '',
|
||||
}
|
||||
result = {
|
||||
to: 'customer@example.com, customer1@example.com, customer2@example.com, customer2+2@example.com',
|
||||
to: 'customer1@example.com, customer2@example.com, customer2+2@example.com, customer@example.com',
|
||||
cc: '',
|
||||
body: '',
|
||||
in_reply_to: 'message_id16',
|
||||
|
@ -2440,6 +2440,45 @@ test('check getRecipientArticle format', function() {
|
|||
verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
|
||||
deepEqual(verify, result)
|
||||
|
||||
agent = {
|
||||
login: 'login',
|
||||
firstname: 'firstname',
|
||||
lastname: 'lastname',
|
||||
email: 'agent@example.com',
|
||||
}
|
||||
ticket = {
|
||||
customer: agent,
|
||||
}
|
||||
article = {
|
||||
message_id: 'message_id19',
|
||||
created_by: agent,
|
||||
type: {
|
||||
name: 'email',
|
||||
},
|
||||
sender: {
|
||||
name: 'Agent',
|
||||
},
|
||||
from: 'Agent <Agent@Example.com>',
|
||||
to: 'Sender <zammad@example.com>',
|
||||
cc: '',
|
||||
}
|
||||
result = {
|
||||
to: 'agent@example.com',
|
||||
cc: '',
|
||||
body: '',
|
||||
in_reply_to: 'message_id19',
|
||||
}
|
||||
email_addresses = [
|
||||
{
|
||||
email: 'zammad@example.com',
|
||||
},
|
||||
{
|
||||
email: 'zammad2@example.com',
|
||||
}
|
||||
]
|
||||
verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
|
||||
deepEqual(verify, result)
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue