Validate if session exists before deleting it

This commit is contained in:
Judson Cairo 2024-08-10 23:15:02 -03:00
parent feb7b795e9
commit 668f477218

View File

@ -227,11 +227,16 @@ export class BaileysStartupService extends ChannelStartupService {
this.client?.ws?.close(); this.client?.ws?.close();
await this.prismaRepository.session.delete({ const sessionExists = await this.prismaRepository.session.findFirst({
where: { where: { sessionId: this.instanceId },
sessionId: this.instanceId,
},
}); });
if (sessionExists) {
await this.prismaRepository.session.delete({
where: {
sessionId: this.instanceId,
},
});
}
} }
public async getProfileName() { public async getProfileName() {