Implement message update handling in BaileysStartupService

This commit is contained in:
Aditya Nandwana 2025-02-13 11:07:18 +05:30
parent c939ed2337
commit 33f7f2932d

View File

@ -1140,6 +1140,27 @@ export class BaileysStartupService extends ChannelStartupService {
);
await this.sendDataWebhook(Events.MESSAGES_EDITED, editedMessage);
const oldMessage = await this.getMessage(editedMessage.key, true);
if ((oldMessage as any)?.id) {
await this.prismaRepository.message.update({
where: { id: (oldMessage as any).id },
data: {
message: editedMessage.editedMessage as any,
messageTimestamp: (editedMessage.timestampMs as Long.Long).toNumber(),
status: 'EDITED',
},
});
await this.prismaRepository.messageUpdate.create({
data: {
fromMe: editedMessage.key.fromMe,
keyId: editedMessage.key.id,
remoteJid: editedMessage.key.remoteJid,
status: 'EDITED',
instanceId: this.instanceId,
messageId: (oldMessage as any).id,
},
});
}
}
}