fix(draft-factory): ReplyTo takes precedence over "from me" #2175

This commit is contained in:
Ben Gotow 2016-05-10 10:33:43 -07:00
parent 5bf245b324
commit eab8cb9085
2 changed files with 35 additions and 10 deletions

View file

@ -23,6 +23,7 @@ let fakeMessage2 = null;
let msgWithReplyTo = null;
let fakeMessageWithFiles = null;
let msgWithReplyToDuplicates = null;
let msgWithReplyToFromMe = null;
let account = null;
describe('DraftFactory', function draftFactory() {
@ -104,6 +105,14 @@ describe('DraftFactory', function draftFactory() {
date: new Date(1415814587),
});
msgWithReplyToFromMe = new Message({
accountId: account.id,
threadId: 'fake-thread-id',
from: [account.me()],
to: [new Contact({email: 'tiffany@popular.com', name: 'Tiffany'})],
replyTo: [new Contact({email: 'danco@gmail.com', name: 'danco@gmail.com'})],
})
msgWithReplyToDuplicates = new Message({
id: 'fake-message-reply-to-duplicates',
accountId: account.id,
@ -246,6 +255,16 @@ describe('DraftFactory', function draftFactory() {
});
});
});
it("addresses the draft to all of the message's 'ReplyTo' recipients, even if the message is 'From' you", () => {
waitsForPromise(() => {
return DraftFactory.createDraftForReply({thread: fakeThread, message: msgWithReplyToFromMe, type: 'reply'}).then((draft) => {
expect(draft.to).toEqual(msgWithReplyToFromMe.replyTo);
expect(draft.cc.length).toBe(0);
expect(draft.bcc.length).toBe(0);
});
});
});
});
describe("when the message provided as context was sent by the current user", () => {
@ -298,6 +317,14 @@ describe('DraftFactory', function draftFactory() {
});
});
it("addresses the draft to all of the message's 'ReplyTo' recipients, even if the message is 'From' you", () => {
waitsForPromise(() => {
return DraftFactory.createDraftForReply({thread: fakeThread, message: msgWithReplyToFromMe, type: 'reply-all'}).then((draft) => {
expect(draft.to).toEqual(msgWithReplyToFromMe.replyTo);
});
});
});
it("should not include the message's 'From' recipient in any field", () => {
waitsForPromise(() => {
return DraftFactory.createDraftForReply({thread: fakeThread, message: msgWithReplyTo, type: 'reply-all'}).then((draft) => {

View file

@ -288,15 +288,14 @@ Message(date DESC) WHERE draft = 1`,
let to = null
let cc = null
if (this.isFromMe()) {
if (this.replyTo.length) {
to = this.replyTo
cc = excludeMeAndFroms([].concat(this.to, this.cc))
} else if (this.isFromMe()) {
to = this.to
cc = excludeMeAndFroms(this.cc)
} else {
if (this.replyTo.length) {
to = this.replyTo
} else {
to = this.from
}
cc = excludeMeAndFroms([].concat(this.to, this.cc))
}
@ -312,10 +311,10 @@ Message(date DESC) WHERE draft = 1`,
let to = []
const cc = []
if (this.isFromMe()) {
if (this.replyTo.length) {
to = this.replyTo;
} else if (this.isFromMe()) {
to = this.to
} else if (this.replyTo.length) {
to = this.replyTo
} else {
to = this.from
}
@ -360,4 +359,3 @@ Message(date DESC) WHERE draft = 1`,
return moment(this.date).format("MMM D YYYY, [at] h:mm a")
}
}