Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5133 Fix broken email threading for draft messages #5874

Merged
merged 9 commits into from
Dec 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
const thread = await this.view.emailProvider.threadGet(this.view.threadId, 'metadata');
const inReplyToMessage = thread.messages?.find(message => message.id === this.view.replyMsgId);
if (inReplyToMessage) {
this.view.replyParams.inReplyTo = inReplyToMessage.payload?.headers?.find(
header => header.name === 'Message-Id' || header.name === 'Message-ID'
)?.value;
const msgId = inReplyToMessage.payload?.headers?.find(header => header.name === 'Message-Id' || header.name === 'Message-ID')?.value;
const references = inReplyToMessage.payload?.headers?.find(header => header.name === 'References')?.value;
if (msgId && references) {
this.setReplyHeaders(msgId, references);
}
martgil marked this conversation as resolved.
Show resolved Hide resolved
}
this.view.replyParams.subject = `${this.responseMethod === 'reply' ? 'Re' : 'Fwd'}: ${this.view.replyParams.subject}`;
if (this.view.useFullScreenSecureCompose) {
Expand All @@ -117,8 +119,7 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
);
if (this.view.quoteModule.messageToReplyOrForward) {
const msgId = this.view.quoteModule.messageToReplyOrForward.headers['message-id'];
this.view.sendBtnModule.additionalMsgHeaders['In-Reply-To'] = msgId;
this.view.sendBtnModule.additionalMsgHeaders.References = this.view.quoteModule.messageToReplyOrForward.headers.references + ' ' + msgId;
this.setReplyHeaders(msgId, this.view.quoteModule.messageToReplyOrForward.headers.references);
if (this.view.replyPubkeyMismatch) {
await this.renderReplyMsgAsReplyPubkeyMismatch();
} else if (this.view.quoteModule.messageToReplyOrForward.isOnlySigned) {
Expand Down Expand Up @@ -273,6 +274,13 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
}
};

private setReplyHeaders = (msgId?: string, references?: string) => {
if (msgId) {
this.view.sendBtnModule.additionalMsgHeaders['In-Reply-To'] = msgId;
this.view.sendBtnModule.additionalMsgHeaders.References = [references, msgId].filter(Boolean).join(' ');
}
};

private initComposeBoxStyles = () => {
if (this.view.isReplyBox) {
this.view.S.cached('body').addClass('reply_box');
Expand Down