Skip to content

Commit 4ed1335

Browse files
committed
changelog
1 parent 4274c7a commit 4ed1335

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/api/services/whatsapp/whatsapp.baileys.service.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ export class BaileysStartupService extends WAStartupService {
135135
this.cleanStore();
136136
this.instance.qrcode = { count: 0 };
137137
this.mobile = false;
138-
139-
setTimeout(() => {
140-
this.recoveringMessages();
141-
}, 30000);
138+
this.recoveringMessages();
142139
}
143140

144141
private readonly msgRetryCounterCache: CacheStore = new NodeCache();
@@ -152,15 +149,19 @@ export class BaileysStartupService extends WAStartupService {
152149
public mobile: boolean;
153150

154151
private async recoveringMessages() {
155-
this.logger.info('Recovering messages');
156-
this.messagesLostCache.keys().then((keys) => {
157-
keys.forEach(async (key) => {
158-
const message = await this.messagesLostCache.get(key.split(':')[2]);
159-
160-
if (message.messageStubParameters && message.messageStubParameters[0] === 'Message absent from node')
161-
await this.client.sendMessageAck(JSON.parse(message.messageStubParameters[1], BufferJSON.reviver));
152+
setTimeout(async () => {
153+
this.logger.info('Recovering messages');
154+
this.messagesLostCache.keys().then((keys) => {
155+
keys.forEach(async (key) => {
156+
const message = await this.messagesLostCache.get(key.split(':')[2]);
157+
158+
if (message.messageStubParameters && message.messageStubParameters[0] === 'Message absent from node') {
159+
this.logger.verbose('Message absent from node, retrying to send, key: ' + key.split(':')[2]);
160+
await this.client.sendMessageAck(JSON.parse(message.messageStubParameters[1], BufferJSON.reviver));
161+
}
162+
});
162163
});
163-
});
164+
}, 30000);
164165
}
165166

166167
public get connectionStatus() {

0 commit comments

Comments
 (0)