mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
fix(draft-factory): ReplyTo takes precedence over "from me" #2175
This commit is contained in:
parent
5bf245b324
commit
eab8cb9085
|
@ -23,6 +23,7 @@ let fakeMessage2 = null;
|
||||||
let msgWithReplyTo = null;
|
let msgWithReplyTo = null;
|
||||||
let fakeMessageWithFiles = null;
|
let fakeMessageWithFiles = null;
|
||||||
let msgWithReplyToDuplicates = null;
|
let msgWithReplyToDuplicates = null;
|
||||||
|
let msgWithReplyToFromMe = null;
|
||||||
let account = null;
|
let account = null;
|
||||||
|
|
||||||
describe('DraftFactory', function draftFactory() {
|
describe('DraftFactory', function draftFactory() {
|
||||||
|
@ -104,6 +105,14 @@ describe('DraftFactory', function draftFactory() {
|
||||||
date: new Date(1415814587),
|
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({
|
msgWithReplyToDuplicates = new Message({
|
||||||
id: 'fake-message-reply-to-duplicates',
|
id: 'fake-message-reply-to-duplicates',
|
||||||
accountId: account.id,
|
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", () => {
|
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", () => {
|
it("should not include the message's 'From' recipient in any field", () => {
|
||||||
waitsForPromise(() => {
|
waitsForPromise(() => {
|
||||||
return DraftFactory.createDraftForReply({thread: fakeThread, message: msgWithReplyTo, type: 'reply-all'}).then((draft) => {
|
return DraftFactory.createDraftForReply({thread: fakeThread, message: msgWithReplyTo, type: 'reply-all'}).then((draft) => {
|
||||||
|
|
|
@ -288,15 +288,14 @@ Message(date DESC) WHERE draft = 1`,
|
||||||
let to = null
|
let to = null
|
||||||
let cc = 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
|
to = this.to
|
||||||
cc = excludeMeAndFroms(this.cc)
|
cc = excludeMeAndFroms(this.cc)
|
||||||
} else {
|
|
||||||
if (this.replyTo.length) {
|
|
||||||
to = this.replyTo
|
|
||||||
} else {
|
} else {
|
||||||
to = this.from
|
to = this.from
|
||||||
}
|
|
||||||
cc = excludeMeAndFroms([].concat(this.to, this.cc))
|
cc = excludeMeAndFroms([].concat(this.to, this.cc))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,10 +311,10 @@ Message(date DESC) WHERE draft = 1`,
|
||||||
let to = []
|
let to = []
|
||||||
const cc = []
|
const cc = []
|
||||||
|
|
||||||
if (this.isFromMe()) {
|
if (this.replyTo.length) {
|
||||||
|
to = this.replyTo;
|
||||||
|
} else if (this.isFromMe()) {
|
||||||
to = this.to
|
to = this.to
|
||||||
} else if (this.replyTo.length) {
|
|
||||||
to = this.replyTo
|
|
||||||
} else {
|
} else {
|
||||||
to = this.from
|
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")
|
return moment(this.date).format("MMM D YYYY, [at] h:mm a")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue