Skip to content

Commit

Permalink
fix(imap): fixed related message error
Browse files Browse the repository at this point in the history
  • Loading branch information
batamar committed Apr 7, 2023
1 parent 052342b commit d28d3f7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/plugin-imap-api/src/utils.ts
Expand Up @@ -161,13 +161,18 @@ const saveMessages = async (

let conversationId;

const $or: any[] = [
{ references: { $in: [msg.messageId] } },
{ messageId: { $in: msg.references || [] } }
];

if (msg.inReplyTo) {
$or.push({ messageId: msg.inReplyTo });
$or.push({ references: { $in: [msg.inReplyTo] } });
}

const relatedMessage = await models.Messages.findOne({
$or: [
{ messageId: msg.inReplyTo },
{ messageId: { $in: msg.references || [] } },
{ references: { $in: [msg.messageId] } },
{ references: { $in: [msg.inReplyTo] } }
]
$or
});

if (relatedMessage) {
Expand Down

0 comments on commit d28d3f7

Please sign in to comment.