mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
Merge branch 'v2.0.0' of github.com:EvolutionAPI/evolution-api into v2.0.0
This commit is contained in:
commit
1d31f533f4
@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[labelId,instanceId]` on the table `Label` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "Label_labelId_key";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Label_labelId_instanceId_key" ON "Label"("labelId", "instanceId");
|
@ -216,7 +216,7 @@ model Chatwoot {
|
||||
|
||||
model Label {
|
||||
id String @id @default(cuid())
|
||||
labelId String? @unique @db.VarChar(100)
|
||||
labelId String? @db.VarChar(100)
|
||||
name String @db.VarChar(100)
|
||||
color String @db.VarChar(100)
|
||||
predefinedId String? @db.VarChar(100)
|
||||
@ -224,6 +224,8 @@ model Label {
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
|
||||
@@unique([labelId, instanceId])
|
||||
}
|
||||
|
||||
model Proxy {
|
||||
|
@ -1454,7 +1454,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const savedLabel = labelsRepository.find((l) => l.labelId === label.id);
|
||||
if (label.deleted && savedLabel) {
|
||||
await this.prismaRepository.label.delete({
|
||||
where: { instanceId: this.instanceId, labelId: label.id },
|
||||
where: { labelId_instanceId: { instanceId: this.instanceId, labelId: label.id } },
|
||||
});
|
||||
this.sendDataWebhook(Events.LABELS_EDIT, { ...label, instance: this.instance.name });
|
||||
return;
|
||||
@ -1462,16 +1462,25 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
const labelName = label.name.replace(/[^\x20-\x7E]/g, '');
|
||||
if (!savedLabel || savedLabel.color !== `${label.color}` || savedLabel.name !== labelName) {
|
||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.LABELS)
|
||||
await this.prismaRepository.label.create({
|
||||
data: {
|
||||
color: `${label.color}`,
|
||||
name: labelName,
|
||||
labelId: label.id,
|
||||
predefinedId: label.predefinedId,
|
||||
instanceId: this.instanceId,
|
||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.LABELS) {
|
||||
const labelData = {
|
||||
color: `${label.color}`,
|
||||
name: labelName,
|
||||
labelId: label.id,
|
||||
predefinedId: label.predefinedId,
|
||||
instanceId: this.instanceId,
|
||||
};
|
||||
await this.prismaRepository.label.upsert({
|
||||
where: {
|
||||
labelId_instanceId: {
|
||||
instanceId: labelData.instanceId,
|
||||
labelId: labelData.labelId,
|
||||
},
|
||||
},
|
||||
update: labelData,
|
||||
create: labelData,
|
||||
});
|
||||
}
|
||||
this.sendDataWebhook(Events.LABELS_EDIT, { ...label, instance: this.instance.name });
|
||||
}
|
||||
},
|
||||
|
@ -120,6 +120,7 @@ export class WAMonitoringService {
|
||||
}
|
||||
|
||||
public async cleaningUp(instanceName: string) {
|
||||
let instanceDbId: string;
|
||||
if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
||||
const instance = await this.prismaRepository.instance.update({
|
||||
where: { name: instanceName },
|
||||
@ -130,13 +131,15 @@ export class WAMonitoringService {
|
||||
|
||||
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
|
||||
|
||||
instanceDbId = instance.id;
|
||||
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
||||
await this.cache.delete(instanceName);
|
||||
return;
|
||||
if (instanceDbId) {
|
||||
await this.cache.delete(instanceDbId);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.providerSession?.ENABLED) {
|
||||
|
Loading…
Reference in New Issue
Block a user