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()
|
article_created_by_email = article_created_by.email.toLowerCase()
|
||||||
|
|
||||||
# check if article sender is local
|
# check if article sender is local
|
||||||
|
senderIsLocal = false
|
||||||
if !_.isEmpty(article.from)
|
if !_.isEmpty(article.from)
|
||||||
senderIsLocal = false
|
|
||||||
senders = emailAddresses.parseAddressList(article.from)
|
senders = emailAddresses.parseAddressList(article.from)
|
||||||
if senders && senders[0] && senders[0].address
|
if senders && senders[0] && senders[0].address
|
||||||
senderIsLocal = isLocalAddress(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
|
# sender is local
|
||||||
if senderIsLocal
|
if senderIsLocal
|
||||||
articleNew.to = article.to
|
articleNew.to = article.to
|
||||||
|
|
||||||
# sender is agent from is different (sender was system)
|
# sender is agent - sent via system
|
||||||
else if article.sender.name is 'Agent' && article_created_by_email && article.from && !article.from.match(article_created_by_email)
|
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
|
articleNew.to = article.to
|
||||||
|
|
||||||
# sender was regular customer
|
# sender was regular customer
|
||||||
|
|
|
@ -1984,11 +1984,11 @@ test('check getRecipientArticle format', function() {
|
||||||
sender: {
|
sender: {
|
||||||
name: 'Agent',
|
name: 'Agent',
|
||||||
},
|
},
|
||||||
from: 'zammad@example.com',
|
from: 'customer2@example.com',
|
||||||
to: 'customer@example.com',
|
to: 'customer@example.com',
|
||||||
}
|
}
|
||||||
result = {
|
result = {
|
||||||
to: 'customer@example.com',
|
to: 'customer2@example.com',
|
||||||
cc: '',
|
cc: '',
|
||||||
body: '',
|
body: '',
|
||||||
in_reply_to: 'message_id7',
|
in_reply_to: 'message_id7',
|
||||||
|
@ -2024,7 +2024,7 @@ test('check getRecipientArticle format', function() {
|
||||||
to: 'customer@example.com',
|
to: 'customer@example.com',
|
||||||
}
|
}
|
||||||
result = {
|
result = {
|
||||||
to: 'agent@example.com',
|
to: 'customer@example.com',
|
||||||
cc: '',
|
cc: '',
|
||||||
body: '',
|
body: '',
|
||||||
in_reply_to: 'message_id8',
|
in_reply_to: 'message_id8',
|
||||||
|
@ -2295,7 +2295,7 @@ test('check getRecipientArticle format', function() {
|
||||||
cc: '',
|
cc: '',
|
||||||
}
|
}
|
||||||
result = {
|
result = {
|
||||||
to: 'customer@example.com, customer1@example.com, customer2@example.com',
|
to: 'customer1@example.com, customer2@example.com, customer@example.com',
|
||||||
cc: '',
|
cc: '',
|
||||||
body: '',
|
body: '',
|
||||||
in_reply_to: 'message_id15',
|
in_reply_to: 'message_id15',
|
||||||
|
@ -2334,7 +2334,7 @@ test('check getRecipientArticle format', function() {
|
||||||
cc: '',
|
cc: '',
|
||||||
}
|
}
|
||||||
result = {
|
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: '',
|
cc: '',
|
||||||
body: '',
|
body: '',
|
||||||
in_reply_to: 'message_id16',
|
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)
|
verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
|
||||||
deepEqual(verify, result)
|
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