Skip to content

Commit 33f7f29

Browse files
committed
Implement message update handling in BaileysStartupService
1 parent c939ed2 commit 33f7f29

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,27 @@ export class BaileysStartupService extends ChannelStartupService {
11401140
);
11411141

11421142
await this.sendDataWebhook(Events.MESSAGES_EDITED, editedMessage);
1143+
const oldMessage = await this.getMessage(editedMessage.key, true);
1144+
if ((oldMessage as any)?.id) {
1145+
await this.prismaRepository.message.update({
1146+
where: { id: (oldMessage as any).id },
1147+
data: {
1148+
message: editedMessage.editedMessage as any,
1149+
messageTimestamp: (editedMessage.timestampMs as Long.Long).toNumber(),
1150+
status: 'EDITED',
1151+
},
1152+
});
1153+
await this.prismaRepository.messageUpdate.create({
1154+
data: {
1155+
fromMe: editedMessage.key.fromMe,
1156+
keyId: editedMessage.key.id,
1157+
remoteJid: editedMessage.key.remoteJid,
1158+
status: 'EDITED',
1159+
instanceId: this.instanceId,
1160+
messageId: (oldMessage as any).id,
1161+
},
1162+
});
1163+
}
11431164
}
11441165
}
11451166

0 commit comments

Comments
 (0)