adjusts in redis

This commit is contained in:
Davidson Gomes 2024-04-09 07:40:45 -03:00
parent 76552f6ae5
commit 5d951a96b5
3 changed files with 16 additions and 15 deletions

View File

@ -72,7 +72,7 @@ export class RedisCache {
try {
this.logger.verbose('setData: ' + field);
const json = JSON.stringify(data, BufferJSON.replacer);
await this.client.hSet(`${this.redisEnv.PREFIX_KEY}-${this.instanceName}`, field, json);
await this.client.hSet(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field, json);
return true;
} catch (error) {
this.logger.error(error);
@ -83,7 +83,7 @@ export class RedisCache {
public async getData(field: string): Promise<any | null> {
try {
this.logger.verbose('getData: ' + field);
const data = await this.client.hGet(`${this.redisEnv.PREFIX_KEY}-${this.instanceName}`, field);
const data = await this.client.hGet(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field);
if (data) {
this.logger.verbose('getData: ' + field + ' success');
@ -101,7 +101,7 @@ export class RedisCache {
public async removeData(field: string): Promise<boolean> {
try {
this.logger.verbose('removeData: ' + field);
await this.client.hDel(`${this.redisEnv.PREFIX_KEY}-${this.instanceName}`, field);
await this.client.hDel(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field);
return true;
} catch (error) {
this.logger.error(error);
@ -111,7 +111,7 @@ export class RedisCache {
public async delAll(hash?: string): Promise<boolean> {
try {
const targetHash = hash || `${this.redisEnv.PREFIX_KEY}-${this.instanceName}`;
const targetHash = hash || this.redisEnv.PREFIX_KEY + ':' + this.instanceName;
this.logger.verbose('instance delAll: ' + targetHash);
const result = await this.client.del(targetHash);
return !!result;

View File

@ -641,8 +641,8 @@ export class InstanceController {
const instance = this.waMonitor.waInstances[instanceName];
console.log('mobileCode', mobileCode);
return await instance.receiveMobileCode(mobileCode);
// return { status: 'SUCCESS', error: false, response: { message: 'Mobile code registered' } };
await instance.receiveMobileCode(mobileCode);
return { status: 'SUCCESS', error: false, response: { message: 'Mobile code registered' } };
} catch (error) {
this.logger.error(error);
}

View File

@ -634,15 +634,16 @@ export class BaileysStartupService extends WAStartupService {
}
public async receiveMobileCode(code: string) {
await this.client
.register(code.replace(/["']/g, '').trim().toLowerCase())
.then(async (response) => {
this.logger.verbose('Registration code received successfully');
console.log(response);
})
.catch((error) => {
this.logger.error(error);
});
console.log('code', code);
// await this.client
// .register(code.replace(/["']/g, '').trim().toLowerCase())
// .then(async (response) => {
// this.logger.verbose('Registration code received successfully');
// console.log(response);
// })
// .catch((error) => {
// this.logger.error(error);
// });
}
public async reloadConnection(): Promise<WASocket> {