mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 17:08:44 -06:00
adjustis in instance controller
This commit is contained in:
parent
bdd1b8fa21
commit
85b0627737
@ -185,8 +185,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await this.forceUpdateGroupMetadataCache();
|
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
await this.forceUpdateGroupMetadataCache();
|
await this.forceUpdateGroupMetadataCache();
|
||||||
}, 3600000);
|
}, 3600000);
|
||||||
@ -208,6 +206,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
await this.client?.logout('Log out instance: ' + this.instanceName);
|
await this.client?.logout('Log out instance: ' + this.instanceName);
|
||||||
|
|
||||||
this.client?.ws?.close();
|
this.client?.ws?.close();
|
||||||
|
|
||||||
|
await this.prismaRepository.session.delete({
|
||||||
|
where: {
|
||||||
|
sessionId: this.instanceId,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getProfileName() {
|
public async getProfileName() {
|
||||||
@ -730,6 +734,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
private readonly chatHandle = {
|
private readonly chatHandle = {
|
||||||
'chats.upsert': async (chats: Chat[]) => {
|
'chats.upsert': async (chats: Chat[]) => {
|
||||||
|
console.log('chats.upsert', chats);
|
||||||
const existingChatIds = await this.prismaRepository.chat.findMany({
|
const existingChatIds = await this.prismaRepository.chat.findMany({
|
||||||
where: { instanceId: this.instanceId },
|
where: { instanceId: this.instanceId },
|
||||||
select: { remoteJid: true },
|
select: { remoteJid: true },
|
||||||
@ -3091,7 +3096,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
public async fetchAllGroups(getParticipants: GetParticipant) {
|
public async fetchAllGroups(getParticipants: GetParticipant) {
|
||||||
try {
|
try {
|
||||||
const fetch = Object.values(await this.client.groupFetchAllParticipating());
|
const fetch = Object.values(await this?.client?.groupFetchAllParticipating());
|
||||||
let groups = [];
|
let groups = [];
|
||||||
for (const group of fetch) {
|
for (const group of fetch) {
|
||||||
const picture = await this.profilePicture(group.id);
|
const picture = await this.profilePicture(group.id);
|
||||||
|
@ -195,12 +195,14 @@ export class WAMonitoringService {
|
|||||||
|
|
||||||
public async cleaningUp(instanceName: string) {
|
public async cleaningUp(instanceName: string) {
|
||||||
if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
||||||
await this.prismaRepository.instance.update({
|
const instance = await this.prismaRepository.instance.update({
|
||||||
where: { name: instanceName },
|
where: { name: instanceName },
|
||||||
data: { connectionStatus: 'close' },
|
data: { connectionStatus: 'close' },
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.prismaRepository.session.deleteMany({ where: { sessionId: instanceName } });
|
if (!instance) this.logger.error('Instance not found');
|
||||||
|
|
||||||
|
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,26 +241,31 @@ export class WAMonitoringService {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const instance = await this.prismaRepository.instance.findFirst({
|
||||||
|
where: { name: instanceName },
|
||||||
|
});
|
||||||
|
|
||||||
await this.prismaRepository.session.deleteMany({ where: { sessionId: instanceName } });
|
rmSync(join(INSTANCE_DIR, instance.id), { recursive: true, force: true });
|
||||||
|
|
||||||
await this.prismaRepository.chat.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.session.deleteMany({ where: { sessionId: instance.id } });
|
||||||
await this.prismaRepository.contact.deleteMany({ where: { instanceId: instanceName } });
|
|
||||||
await this.prismaRepository.messageUpdate.deleteMany({ where: { instanceId: instanceName } });
|
|
||||||
await this.prismaRepository.message.deleteMany({ where: { instanceId: instanceName } });
|
|
||||||
|
|
||||||
await this.prismaRepository.integration.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.chat.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.auth.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.contact.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.webhook.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.messageUpdate.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.chatwoot.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.message.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.proxy.deleteMany({ where: { instanceId: instanceName } });
|
|
||||||
await this.prismaRepository.rabbitmq.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.integration.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.sqs.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.auth.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.typebotSession.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.webhook.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.typebot.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.chatwoot.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.websocket.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.proxy.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.setting.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.rabbitmq.deleteMany({ where: { instanceId: instance.id } });
|
||||||
await this.prismaRepository.label.deleteMany({ where: { instanceId: instanceName } });
|
await this.prismaRepository.sqs.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
await this.prismaRepository.typebotSession.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
await this.prismaRepository.typebot.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
await this.prismaRepository.websocket.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
await this.prismaRepository.setting.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
await this.prismaRepository.label.deleteMany({ where: { instanceId: instance.id } });
|
||||||
|
|
||||||
await this.prismaRepository.instance.delete({ where: { name: instanceName } });
|
await this.prismaRepository.instance.delete({ where: { name: instanceName } });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user