This commit is contained in:
Alan Mosko
2023-07-26 10:30:26 -03:00
parent cc91f2e5db
commit e151eb85f0
55 changed files with 340 additions and 273 deletions

View File

@@ -1,8 +1,9 @@
import { Express } from 'express';
import { readFileSync } from 'fs';
import { configService, SslConf } from '../config/env.config';
import * as https from 'https';
import * as http from 'http';
import * as https from 'https';
import { configService, SslConf } from '../config/env.config';
export class ServerUP {
static #app: Express;

View File

@@ -6,6 +6,7 @@ import {
proto,
SignalDataTypeMap,
} from '@whiskeysockets/baileys';
import { configService, Database } from '../config/env.config';
import { Logger } from '../config/logger.config';
import { dbserver } from '../db/db.connect';
@@ -29,7 +30,9 @@ export async function useMultiFileAuthStateDb(
JSON.parse(JSON.stringify(data, BufferJSON.replacer)),
{ upsert: true },
);
} catch {}
} catch (error) {
logger.error(error);
}
};
const readData = async (key: string): Promise<any> => {
@@ -38,14 +41,18 @@ export async function useMultiFileAuthStateDb(
const data = await collection.findOne({ _id: key });
const creds = JSON.stringify(data);
return JSON.parse(creds, BufferJSON.reviver);
} catch {}
} catch (error) {
logger.error(error);
}
};
const removeData = async (key: string) => {
try {
await client.connect();
return await collection.deleteOne({ _id: key });
} catch {}
} catch (error) {
logger.error(error);
}
};
const creds: AuthenticationCreds = (await readData('creds')) || initAuthCreds();

View File

@@ -5,9 +5,10 @@ import {
proto,
SignalDataTypeMap,
} from '@whiskeysockets/baileys';
import { RedisCache } from '../db/redis.client';
import { Logger } from '../config/logger.config';
import { Redis } from '../config/env.config';
import { Logger } from '../config/logger.config';
import { RedisCache } from '../db/redis.client';
export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
state: AuthenticationState;