mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-11 19:09:39 -06:00
lint
This commit is contained in:
parent
be5760905e
commit
45e461e757
@ -273,19 +273,19 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
if (provider?.ENABLED) {
|
if (provider?.ENABLED) {
|
||||||
const authState = await this.authStateProvider.authStateProvider(this.instance.id);
|
const authState = await this.authStateProvider.authStateProvider(this.instance.id);
|
||||||
|
|
||||||
await authState.removeCreds()
|
await authState.removeCreds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache?.REDIS.ENABLED && cache?.REDIS.SAVE_INSTANCES) {
|
if (cache?.REDIS.ENABLED && cache?.REDIS.SAVE_INSTANCES) {
|
||||||
const authState = await useMultiFileAuthStateRedisDb(this.instance.id, this.cache);
|
const authState = await useMultiFileAuthStateRedisDb(this.instance.id, this.cache);
|
||||||
|
|
||||||
await authState.removeCreds()
|
await authState.removeCreds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db.SAVE_DATA.INSTANCE) {
|
if (db.SAVE_DATA.INSTANCE) {
|
||||||
const authState = await useMultiFileAuthStatePrisma(this.instance.id, this.cache);
|
const authState = await useMultiFileAuthStatePrisma(this.instance.id, this.cache);
|
||||||
|
|
||||||
await authState.removeCreds()
|
await authState.removeCreds();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionExists = await this.prismaRepository.session.findFirst({ where: { sessionId: this.instanceId } });
|
const sessionExists = await this.prismaRepository.session.findFirst({ where: { sessionId: this.instanceId } });
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { prismaRepository } from '@api/server.module';
|
import { prismaRepository } from '@api/server.module';
|
||||||
import { CacheService } from '@api/services/cache.service';
|
import { CacheService } from '@api/services/cache.service';
|
||||||
import { CacheConf, configService } from '@config/env.config';
|
import { CacheConf, configService } from '@config/env.config';
|
||||||
|
import { Logger } from '@config/logger.config';
|
||||||
import { INSTANCE_DIR } from '@config/path.config';
|
import { INSTANCE_DIR } from '@config/path.config';
|
||||||
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {Logger} from "@config/logger.config";
|
|
||||||
|
|
||||||
const fixFileName = (file: string): string | undefined => {
|
const fixFileName = (file: string): string | undefined => {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@ -147,7 +147,6 @@ export default async function useMultiFileAuthStatePrisma(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function removeCreds(): Promise<any> {
|
async function removeCreds(): Promise<any> {
|
||||||
|
|
||||||
const cacheConfig = configService.get<CacheConf>('CACHE');
|
const cacheConfig = configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
// Redis
|
// Redis
|
||||||
@ -156,7 +155,7 @@ export default async function useMultiFileAuthStatePrisma(
|
|||||||
await cache.delete(sessionId);
|
await cache.delete(sessionId);
|
||||||
logger.info({ action: 'redis.delete', sessionId });
|
logger.info({ action: 'redis.delete', sessionId });
|
||||||
|
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn({ action: 'redis.delete', sessionId, err });
|
logger.warn({ action: 'redis.delete', sessionId, err });
|
||||||
@ -209,6 +208,6 @@ export default async function useMultiFileAuthStatePrisma(
|
|||||||
return writeData(creds, 'creds');
|
return writeData(creds, 'creds');
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCreds
|
removeCreds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ import { isNotEmpty } from 'class-validator';
|
|||||||
|
|
||||||
export type AuthState = {
|
export type AuthState = {
|
||||||
state: AuthenticationState;
|
state: AuthenticationState;
|
||||||
saveCreds: () => Promise<void>
|
saveCreds: () => Promise<void>;
|
||||||
removeCreds: () => Promise<void>;
|
removeCreds: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,7 +91,6 @@ export class AuthStateProvider {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const removeCreds = async () => {
|
const removeCreds = async () => {
|
||||||
|
|
||||||
const [response, error] = await this.providerFiles.removeSession(instance);
|
const [response, error] = await this.providerFiles.removeSession(instance);
|
||||||
if (error) {
|
if (error) {
|
||||||
// this.logger.error(['removeData', error?.message, error?.stack]);
|
// this.logger.error(['removeData', error?.message, error?.stack]);
|
||||||
@ -144,7 +143,7 @@ export class AuthStateProvider {
|
|||||||
return await writeData(creds, 'creds');
|
return await writeData(creds, 'creds');
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCreds
|
removeCreds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,6 @@ export async function useMultiFileAuthStateRedisDb(
|
|||||||
|
|
||||||
async function removeCreds(): Promise<any> {
|
async function removeCreds(): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
logger.warn({ action: 'redis.delete', instanceName });
|
logger.warn({ action: 'redis.delete', instanceName });
|
||||||
|
|
||||||
return await cache.delete(instanceName);
|
return await cache.delete(instanceName);
|
||||||
@ -89,6 +88,6 @@ export async function useMultiFileAuthStateRedisDb(
|
|||||||
return await writeData(creds, 'creds');
|
return await writeData(creds, 'creds');
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCreds
|
removeCreds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user