Fetch message history at startup
This commit is contained in:
parent
0c287e38d3
commit
a2fc38db25
1 changed files with 12 additions and 0 deletions
|
|
@ -98,6 +98,7 @@ export default class WhatsappService extends Service {
|
|||
...options,
|
||||
auth: state,
|
||||
generateHighQualityLinkPreview: false,
|
||||
syncFullHistory: true,
|
||||
msgRetryCounterMap,
|
||||
shouldIgnoreJid: (jid) => isJidBroadcast(jid) || isJidStatusBroadcast(jid),
|
||||
});
|
||||
|
|
@ -148,6 +149,17 @@ export default class WhatsappService extends Service {
|
|||
await this.queueUnreadMessages(botID, messages);
|
||||
}
|
||||
}
|
||||
|
||||
if (events["messaging-history.set"]) {
|
||||
const { messages, isLatest } = events["messaging-history.set"];
|
||||
logger.info(
|
||||
{ messageCount: messages.length, isLatest },
|
||||
"received message history on connection",
|
||||
);
|
||||
if (messages.length > 0) {
|
||||
await this.queueUnreadMessages(botID, messages);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.connections[botID] = { socket, msgRetryCounterMap };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue