summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/services/model/mail.js35
-rw-r--r--web-ui/test/spec/services/model/mail.spec.js40
-rw-r--r--web-ui/test/test_data.js67
3 files changed, 66 insertions, 76 deletions
diff --git a/web-ui/app/js/services/model/mail.js b/web-ui/app/js/services/model/mail.js
index f2103262..870c6a80 100644
--- a/web-ui/app/js/services/model/mail.js
+++ b/web-ui/app/js/services/model/mail.js
@@ -30,15 +30,6 @@ define(['helpers/contenttype'],
return this.mailbox === 'DRAFTS';
}
- function normalize(recipients) {
- return _.chain([recipients])
- .flatten()
- .filter(function (r) {
- return !_.isUndefined(r) && !_.isEmpty(r);
- })
- .value();
- }
-
function isInTrash() {
return _.contains(this.tags, 'trash');
}
@@ -47,32 +38,17 @@ define(['helpers/contenttype'],
this.draft_reply_for = ident;
}
- function recipients(){
+ function replyToAddress() {
return {
- to: normalize(this.header.to),
- cc: normalize(this.header.cc)
+ to: [this.replying.single],
+ cc: []
};
}
- function replyToAddress() {
- var recipients;
-
- if (this.isSentMail()) {
- recipients = this.recipients();
- } else {
- recipients = {
- to: normalize(this.header.reply_to || this.header.from),
- cc: []
- };
- }
-
- return recipients;
- }
-
function replyToAllAddress() {
return {
- to: normalize([this.header.reply_to, this.header.from]),
- cc: normalize(this.header.cc)
+ to: this.replying.all['to-field'],
+ cc: this.replying.all['cc-field']
};
}
@@ -142,7 +118,6 @@ define(['helpers/contenttype'],
this.setDraftReplyFor = setDraftReplyFor;
this.replyToAddress = replyToAddress;
this.replyToAllAddress = replyToAllAddress;
- this.recipients = recipients;
this.getMailMediaType = getMailMediaType;
this.isMailMultipartAlternative = isMailMultipartAlternative;
this.getMailMultiParts = getMailMultiParts;
diff --git a/web-ui/test/spec/services/model/mail.spec.js b/web-ui/test/spec/services/model/mail.spec.js
index 3ee936f6..2cbd21e9 100644
--- a/web-ui/test/spec/services/model/mail.spec.js
+++ b/web-ui/test/spec/services/model/mail.spec.js
@@ -2,23 +2,8 @@
require(['services/model/mail'], function (Mail) {
'use strict';
- var testData;
describe('services/model/mail', function () {
- describe('reply addresses', function () {
- it('returns the "to" and "cc" addresses if the mail was sent', function () {
- var mail = Mail.create({
- header: { to: ['a@b.c', 'e@f.g'], cc: ['x@x.x'] },
- tags: [],
- mailbox: 'SENT'
- });
-
- var addresses = mail.replyToAddress();
-
- expect(addresses).toEqual({ to: ['a@b.c', 'e@f.g'], cc: ['x@x.x']});
- });
- });
-
describe('parsing', function () {
describe('a single email', function () {
var sentMail, draftMail, recievedMail, recievedMailWithCC, rawMailWithMultipleTo;
@@ -42,31 +27,6 @@ require(['services/model/mail'], function (Mail) {
expect(recievedMail.isSentMail()).toBe(false);
expect(recievedMail.isDraftMail()).toBe(false);
});
-
- it('reply to of a sent mail should be original recipient', function () {
- expect(sentMail.replyToAddress()).toEqual({to: ['mariane_dach@davis.info'], cc: ['duda@la.lu']});
- });
-
- it('reply to of a mail should be the reply_to field if existent', function () {
- expect(recievedMail.replyToAddress()).toEqual({to: ['afton_braun@botsford.biz'], cc: [] });
- });
-
- it('reply to of a mail should be the from field if no reply_to present', function () {
- expect(recievedMailWithCC.replyToAddress()).toEqual({to: ['cleve_jaskolski@schimmelhirthe.net'], cc: []});
- });
-
- it('reply to all should include all email addresses in the header', function () {
- expect(recievedMailWithCC.replyToAllAddress()).toEqual({
- to: ['cleve_jaskolski@schimmelhirthe.net'],
- cc: ['mariane_dach@davis.info']
- });
- });
- it('reply to all should include all email addresses in the header even for multiple to addresses', function () {
- expect(rawMailWithMultipleTo.replyToAllAddress()).toEqual({
- to: ['cleve_jaskolski@schimmelhirthe.net', 'someoneelse@some-other-domain.tld'],
- cc: ['mariane_dach@davis.info']
- });
- });
});
describe('multipart email', function () {
diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js
index 1ea68c55..018c3143 100644
--- a/web-ui/test/test_data.js
+++ b/web-ui/test/test_data.js
@@ -16,6 +16,13 @@ define(function() {
security_casing: {
locks: [],
imprints: []
+ },
+ replying: {
+ single: 'laurel@hamil.info',
+ all: {
+ 'to-field': ['laurel@hamil.info'],
+ 'cc-field': []
+ }
}
};
@@ -25,7 +32,15 @@ define(function() {
'tags':['photography','sky'],
'status':['read'],
'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.',
- 'mailbox': 'SENT'
+ 'mailbox': 'SENT',
+ replying: {
+ single: 'laurel@hamil.info',
+ all: {
+ 'to-field': ['mariane_dach@davis.info'],
+ 'cc-field': ['duda@la.lu']
+ }
+ }
+
};
var rawDraftMail = {
@@ -34,7 +49,15 @@ define(function() {
'tags':['photography','sky'],
'status':['read'],
'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.',
- 'mailbox': 'DRAFTS'
+ 'mailbox': 'DRAFTS',
+ replying: {
+ single: 'afton_braun@botsford.biz',
+ all: {
+ 'to-field': ['afton_braun@botsford.biz'],
+ 'cc-field': []
+ }
+ }
+
};
var rawRecievedMail = {
@@ -42,7 +65,15 @@ define(function() {
'ident':242,
'tags':['garden','instalovers','popularpic'],
'status':['read'],
- 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.'
+ 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.',
+ replying: {
+ single: 'afton_braun@botsford.biz',
+ all: {
+ 'to-field': ['cleve_jaskolski@schimmelhirthe.net', 'afton_braun@botsford.biz'],
+ 'cc-field': []
+ }
+ }
+
};
var rawRecievedWithCCMail = {
@@ -50,7 +81,15 @@ define(function() {
'ident':242,
'tags':['garden','instalovers','popularpic'],
'status':['read'],
- 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.'
+ 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.',
+ replying: {
+ single: 'cleve_jaskolski@schimmelhirthe.net',
+ all: {
+ 'to-field': ['cleve_jaskolski@schimmelhirthe.net'],
+ 'cc-field': ['mariane_dach@davis.info']
+ }
+ }
+
};
var rawMailWithMultipleTo = {
@@ -58,7 +97,15 @@ define(function() {
'ident':242,
'tags':['garden','instalovers','popularpic'],
'status':['read'],
- 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.'
+ 'body':'Sed est neque tempore. Alias officiis pariatur ullam porro corporis. Tempore eum quia placeat. Sapiente fuga cum.',
+ replying: {
+ single: 'cleve_jaskolski@schimmelhirthe.net',
+ all: {
+ 'to-field': ['cleve_jaskolski@schimmelhirthe.net', 'someoneelse@some-other-domain.tld'],
+ 'cc-field': ['mariane_dach@davis.info']
+ }
+ }
+
};
var rawMultipartMail = {
@@ -81,7 +128,15 @@ define(function() {
'Content-Transfer-Encoding: quoted-printable\n' +
'\n' +
'<p><b>Hello everyone!</b></p>\n' +
- '--asdfghjkl--\n'
+ '--asdfghjkl--\n',
+ replying: {
+ single: 'laurel@hamil.info',
+ all: {
+ 'to-field': ['laurel@hamil.info'],
+ 'cc-field': []
+ }
+ }
+
};
var simpleTextPlainMail = {