mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
chore: Remove unused fileExists function in use-multi-file-auth-state-prisma.ts
Explanation: This commit removes an unused `fileExists` function from the `use-multi-file-auth-state-prisma.ts` file. This change simplifies the code and reduces the potential for confusion or maintenance issues in the future. The previously implemented `fileExists` function was commented out and not used in any other part of the file, so it was safe to remove. This change does not affect the functionality of the module and is a pure code improvement. Affected files: - `src/utils/use-multi-file-auth-state-prisma.ts`
This commit is contained in:
parent
634ee9b4b3
commit
a52a687493
@ -8,21 +8,20 @@ import { prismaServer } from '../libs/prisma.connect';
|
||||
|
||||
const prisma = prismaServer;
|
||||
|
||||
const fixFileName = (file: string): string | undefined => {
|
||||
if (!file) {
|
||||
return undefined;
|
||||
}
|
||||
const replacedSlash = file.replace(/\//g, '__');
|
||||
const replacedColon = replacedSlash.replace(/:/g, '-');
|
||||
return replacedColon;
|
||||
};
|
||||
// const fixFileName = (file: string): string | undefined => {
|
||||
// if (!file) {
|
||||
// return undefined;
|
||||
// }
|
||||
// const replacedSlash = file.replace(/\//g, '__');
|
||||
// const replacedColon = replacedSlash.replace(/:/g, '-');
|
||||
// return replacedColon;
|
||||
// };
|
||||
|
||||
export async function keyExists(sessionId: string): Promise<any> {
|
||||
try {
|
||||
const key = await prisma.session.findUnique({ where: { sessionId: sessionId } });
|
||||
return !!key;
|
||||
} catch (error) {
|
||||
console.log(`${error}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -42,7 +41,6 @@ export async function saveKey(sessionId: string, keyJson: any): Promise<any> {
|
||||
data: { creds: JSON.stringify(keyJson) },
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(`${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -54,7 +52,6 @@ export async function getAuthKey(sessionId: string): Promise<any> {
|
||||
const auth = await prisma.session.findUnique({ where: { sessionId: sessionId } });
|
||||
return JSON.parse(auth?.creds);
|
||||
} catch (error) {
|
||||
console.log(`${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -64,20 +61,20 @@ async function deleteAuthKey(sessionId: string): Promise<any> {
|
||||
const register = await keyExists(sessionId);
|
||||
if (!register) return;
|
||||
await prisma.session.delete({ where: { sessionId: sessionId } });
|
||||
} catch (error) {
|
||||
console.log('2', `${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function fileExists(file: string): Promise<any> {
|
||||
try {
|
||||
const stat = await fs.stat(file);
|
||||
if (stat.isFile()) return true;
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// async function fileExists(file: string): Promise<any> {
|
||||
// try {
|
||||
// const stat = await fs.stat(file);
|
||||
// if (stat.isFile()) return true;
|
||||
// } catch (error) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
export default async function useMultiFileAuthStatePrisma(
|
||||
sessionId: string,
|
||||
cache: CacheService,
|
||||
@ -86,7 +83,7 @@ export default async function useMultiFileAuthStatePrisma(
|
||||
saveCreds: () => Promise<void>;
|
||||
}> {
|
||||
const localFolder = path.join(INSTANCE_DIR, sessionId);
|
||||
const localFile = (key: string) => path.join(localFolder, fixFileName(key) + '.json');
|
||||
// const localFile = (key: string) => path.join(localFolder, fixFileName(key) + '.json');
|
||||
await fs.mkdir(localFolder, { recursive: true });
|
||||
|
||||
async function writeData(data: any, key: string): Promise<any> {
|
||||
|
Loading…
Reference in New Issue
Block a user