Skip to content

Commit

Permalink
fix: Fixed getMessageById when the message is from status (wppconnect…
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 22, 2022
1 parent 117bf13 commit f075cd2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/chat/functions/getMessageById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Debug from 'debug';

import { assertGetChat } from '../../assert';
import { WPPError } from '../../util';
import { MsgKey, MsgModel } from '../../whatsapp';
import { MsgKey, MsgModel, MsgStore } from '../../whatsapp';

const debug = Debug('WA-JS:message:getMessageById');

Expand Down Expand Up @@ -68,15 +68,19 @@ export async function getMessageById(

const msgs: MsgModel[] = [];
for (const msgKey of msgsKeys) {
const chat = assertGetChat(msgKey.remote);
let msg = chat.msgs.get(msgKey);
let msg = MsgStore.get(msgKey);

if (!msg) {
debug(`searching remote message with id ${msgKey.toString()}`);
const result = chat.getSearchContext(msgKey);
await result.collection.loadAroundPromise;

const chat = assertGetChat(msgKey.remote);
msg = chat.msgs.get(msgKey);

if (!msg) {
debug(`searching remote message with id ${msgKey.toString()}`);
const result = chat.getSearchContext(msgKey);
await result.collection.loadAroundPromise;

msg = chat.msgs.get(msgKey);
}
}

if (!msg) {
Expand Down

0 comments on commit f075cd2

Please sign in to comment.