mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Merge pull request #1190 from GrimBit1/main
Fix Message deletion in Whatsapp Bailey Service
This commit is contained in:
commit
ff5a8adc71
@ -3552,25 +3552,31 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
const messageId = response.message?.protocolMessage?.key?.id;
|
const messageId = response.message?.protocolMessage?.key?.id;
|
||||||
if (messageId) {
|
if (messageId) {
|
||||||
const isLogicalDeleted = configService.get<Database>('DATABASE').DELETE_DATA.LOGICAL_MESSAGE_DELETE;
|
const isLogicalDeleted = configService.get<Database>('DATABASE').DELETE_DATA.LOGICAL_MESSAGE_DELETE;
|
||||||
let message = await this.prismaRepository.message.findUnique({
|
let message = await this.prismaRepository.message.findFirst({
|
||||||
where: { id: messageId },
|
where: {
|
||||||
|
key: {
|
||||||
|
path: ['id'],
|
||||||
|
equals: messageId,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (isLogicalDeleted) {
|
if (isLogicalDeleted) {
|
||||||
if (!message) return response;
|
if (!message) return response;
|
||||||
const existingKey = typeof message?.key === 'object' && message.key !== null ? message.key : {};
|
const existingKey = typeof message?.key === 'object' && message.key !== null ? message.key : {};
|
||||||
message = await this.prismaRepository.message.update({
|
message = await this.prismaRepository.message.update({
|
||||||
where: { id: messageId },
|
where: { id: message.id },
|
||||||
data: {
|
data: {
|
||||||
key: {
|
key: {
|
||||||
...existingKey,
|
...existingKey,
|
||||||
deleted: true,
|
deleted: true,
|
||||||
},
|
},
|
||||||
|
status: 'DELETED',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.prismaRepository.message.deleteMany({
|
await this.prismaRepository.message.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
id: messageId,
|
id: message.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3579,7 +3585,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
instanceId: message.instanceId,
|
instanceId: message.instanceId,
|
||||||
key: message.key,
|
key: message.key,
|
||||||
messageType: message.messageType,
|
messageType: message.messageType,
|
||||||
status: message.status,
|
status: 'DELETED',
|
||||||
source: message.source,
|
source: message.source,
|
||||||
messageTimestamp: message.messageTimestamp,
|
messageTimestamp: message.messageTimestamp,
|
||||||
pushName: message.pushName,
|
pushName: message.pushName,
|
||||||
|
Loading…
Reference in New Issue
Block a user