Skip to content

Commit 2e89a0e

Browse files
authored
fix(addAsync-thread): ZMSA-2: message addAsync, if a message is referenced then use reference's thread (#889)
* message addAsync, if a message is referenced then use reference's thread * access referenced message through other object in addAsync, fix if statement
1 parent 35ed9fc commit 2e89a0e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/api/messages.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,8 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
25242524
.concat('unseen' in result.value ? (result.value.unseen ? [] : '\\Seen') : [])
25252525
.concat('flagged' in result.value ? (result.value.flagged ? '\\Flagged' : []) : [])
25262526
.concat('draft' in result.value ? (result.value.draft ? '\\Draft' : []) : []),
2527-
raw
2527+
raw,
2528+
referencedMessage: referencedMessage || false
25282529
});
25292530
status = resp.status;
25302531
messageData = resp.data;

lib/message-handler.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,21 @@ class MessageHandler {
606606
return rollback(err);
607607
}
608608

609+
// If referencing a message then use referenced message's thread
610+
if (
611+
options?.referencedMessage?.thread &&
612+
['reply', 'replyAll'].includes(options?.meta?.reference?.action) &&
613+
this.normalizeSubject(subject, {
614+
removePrefix: true
615+
}) ===
616+
this.normalizeSubject(options?.referencedMessage?.subject || '', {
617+
removePrefix: true
618+
}) &&
619+
thread !== options.referencedMessage.thread
620+
) {
621+
thread = options.referencedMessage.thread;
622+
}
623+
609624
messageData.thread = thread;
610625

611626
let insertRes;

0 commit comments

Comments
 (0)