Skip to content

Commit 7d7bd90

Browse files
committed
evolution_fix_delete_message
1 parent 52a6279 commit 7d7bd90

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

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

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class BaileysStartupService extends ChannelStartupService {
382382
qrcodeTerminal.generate(qr, { small: true }, (qrcode) =>
383383
this.logger.log(
384384
`\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` +
385-
qrcode,
385+
qrcode,
386386
),
387387
);
388388

@@ -1023,18 +1023,18 @@ export class BaileysStartupService extends ChannelStartupService {
10231023

10241024
const messagesRepository: Set<string> = new Set(
10251025
chatwootImport.getRepositoryMessagesCache(instance) ??
1026-
(
1027-
await this.prismaRepository.message.findMany({
1028-
select: { key: true },
1029-
where: { instanceId: this.instanceId },
1030-
})
1031-
).map((message) => {
1032-
const key = message.key as {
1033-
id: string;
1034-
};
1035-
1036-
return key.id;
1037-
}),
1026+
(
1027+
await this.prismaRepository.message.findMany({
1028+
select: { key: true },
1029+
where: { instanceId: this.instanceId },
1030+
})
1031+
).map((message) => {
1032+
const key = message.key as {
1033+
id: string;
1034+
};
1035+
1036+
return key.id;
1037+
}),
10381038
);
10391039

10401040
if (chatwootImport.getRepositoryMessagesCache(instance) === null) {
@@ -1508,12 +1508,28 @@ export class BaileysStartupService extends ChannelStartupService {
15081508
},
15091509
});
15101510

1511+
console.dir({findMessage});
1512+
15111513
if (!findMessage) {
15121514
continue;
15131515
}
15141516

15151517
if (update.message === null && update.status === undefined) {
1516-
this.sendDataWebhook(Events.MESSAGES_DELETE, key);
1518+
1519+
const deletedMessage = {
1520+
id: findMessage.id,
1521+
instanceId: this.instanceId,
1522+
key: key,
1523+
messageType: findMessage.messageType,
1524+
status: 'DELETED',
1525+
source: findMessage.source,
1526+
messageTimestamp: findMessage.messageTimestamp,
1527+
pushName: findMessage.pushName,
1528+
participant: findMessage.participant,
1529+
message: findMessage.message,
1530+
}
1531+
1532+
this.sendDataWebhook(Events.MESSAGES_DELETE, deletedMessage);
15171533

15181534
const message: any = {
15191535
messageId: findMessage.id,
@@ -1870,7 +1886,7 @@ export class BaileysStartupService extends ChannelStartupService {
18701886

18711887
try {
18721888
const profilePictureUrl = await this.client.profilePictureUrl(jid, 'image');
1873-
console.dir({profilePictureUrl});
1889+
console.dir({ profilePictureUrl });
18741890

18751891
return {
18761892
wuid: jid,

0 commit comments

Comments
 (0)