Skip to content

Commit 353f167

Browse files
fix(history-sync): emit completion before contact upsert
1 parent 94d6774 commit 353f167

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,6 @@ export class BaileysStartupService extends ChannelStartupService {
10921092
const filteredContacts = contacts.filter((c) => !!c.notify || !!c.name);
10931093
this.historySyncContactCount += filteredContacts.length;
10941094

1095-
await this.contactHandle['contacts.upsert'](
1096-
filteredContacts.map((c) => ({ id: c.id, name: c.name ?? c.notify })),
1097-
);
1098-
10991095
if (progress === 100) {
11001096
this.sendDataWebhook(Events.MESSAGING_HISTORY_SET, {
11011097
messageCount: this.historySyncMessageCount,
@@ -1109,6 +1105,10 @@ export class BaileysStartupService extends ChannelStartupService {
11091105
this.historySyncLastProgress = -1;
11101106
}
11111107

1108+
await this.contactHandle['contacts.upsert'](
1109+
filteredContacts.map((c) => ({ id: c.id, name: c.name ?? c.notify })),
1110+
);
1111+
11121112
contacts = undefined;
11131113
messages = undefined;
11141114
chats = undefined;

0 commit comments

Comments
 (0)