evolution_fix_delete_message

This commit is contained in:
pedro-php 2025-05-05 18:01:24 -03:00
parent 52a6279402
commit 7d7bd904f9

View File

@ -382,7 +382,7 @@ export class BaileysStartupService extends ChannelStartupService {
qrcodeTerminal.generate(qr, { small: true }, (qrcode) => qrcodeTerminal.generate(qr, { small: true }, (qrcode) =>
this.logger.log( this.logger.log(
`\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` + `\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` +
qrcode, qrcode,
), ),
); );
@ -1023,18 +1023,18 @@ export class BaileysStartupService extends ChannelStartupService {
const messagesRepository: Set<string> = new Set( const messagesRepository: Set<string> = new Set(
chatwootImport.getRepositoryMessagesCache(instance) ?? chatwootImport.getRepositoryMessagesCache(instance) ??
( (
await this.prismaRepository.message.findMany({ await this.prismaRepository.message.findMany({
select: { key: true }, select: { key: true },
where: { instanceId: this.instanceId }, where: { instanceId: this.instanceId },
}) })
).map((message) => { ).map((message) => {
const key = message.key as { const key = message.key as {
id: string; id: string;
}; };
return key.id; return key.id;
}), }),
); );
if (chatwootImport.getRepositoryMessagesCache(instance) === null) { if (chatwootImport.getRepositoryMessagesCache(instance) === null) {
@ -1508,12 +1508,28 @@ export class BaileysStartupService extends ChannelStartupService {
}, },
}); });
console.dir({findMessage});
if (!findMessage) { if (!findMessage) {
continue; continue;
} }
if (update.message === null && update.status === undefined) { if (update.message === null && update.status === undefined) {
this.sendDataWebhook(Events.MESSAGES_DELETE, key);
const deletedMessage = {
id: findMessage.id,
instanceId: this.instanceId,
key: key,
messageType: findMessage.messageType,
status: 'DELETED',
source: findMessage.source,
messageTimestamp: findMessage.messageTimestamp,
pushName: findMessage.pushName,
participant: findMessage.participant,
message: findMessage.message,
}
this.sendDataWebhook(Events.MESSAGES_DELETE, deletedMessage);
const message: any = { const message: any = {
messageId: findMessage.id, messageId: findMessage.id,
@ -1870,7 +1886,7 @@ export class BaileysStartupService extends ChannelStartupService {
try { try {
const profilePictureUrl = await this.client.profilePictureUrl(jid, 'image'); const profilePictureUrl = await this.client.profilePictureUrl(jid, 'image');
console.dir({profilePictureUrl}); console.dir({ profilePictureUrl });
return { return {
wuid: jid, wuid: jid,