Skip to content

Commit 555fa66

Browse files
octo-patchocto-patch
andauthored
fix: use correct Prisma JSON path filter in getLastMessage (fixes #2495) (#2515)
The `getLastMessage` function was using an invalid Prisma where-clause syntax `{ key: { remoteJid: number } }` for a JSON/JSONB field. Prisma requires `{ key: { path: ['remoteJid'], equals: value } }` to filter on a JSON field path. This caused a PrismaClientValidationError whenever `archiveChat` or `markChatUnread` called `getLastMessage` with a chat number instead of providing lastMessage directly. Co-authored-by: octo-patch <octo-patch@github.com>
1 parent 0980928 commit 555fa66

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4164,7 +4164,7 @@ export class BaileysStartupService extends ChannelStartupService {
41644164
}
41654165

41664166
public async getLastMessage(number: string) {
4167-
const where: any = { key: { remoteJid: number }, instanceId: this.instance.id };
4167+
const where: any = { key: { path: ['remoteJid'], equals: number }, instanceId: this.instanceId };
41684168

41694169
const messages = await this.prismaRepository.message.findMany({
41704170
where,

0 commit comments

Comments
 (0)