From 34c53d352a922a82bd923312720610f37dd2ef2d Mon Sep 17 00:00:00 2001 From: Judson Cairo Date: Wed, 7 Feb 2024 15:16:37 -0300 Subject: [PATCH] Refactor code and remove commented out sections --- src/utils/i18n.ts | 4 ---- src/whatsapp/abstract/abstract.router.ts | 5 ----- src/whatsapp/controllers/settings.controller.ts | 3 --- src/whatsapp/routers/chatwoot.router.ts | 1 - src/whatsapp/routers/settings.router.ts | 1 - src/whatsapp/services/chatwoot.service.ts | 10 ---------- 6 files changed, 24 deletions(-) diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index 65feab48..74a76724 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -4,8 +4,6 @@ import path from 'path'; import { ConfigService, Language } from '../config/env.config'; -// export class i18n { -// constructor(private readonly configService: ConfigService) { const languages = ['en', 'pt-BR']; const translationsPath = path.join(__dirname, 'translations'); const configService: ConfigService = new ConfigService(); @@ -31,6 +29,4 @@ i18next.init({ escapeValue: false, }, }); -// } -// } export default i18next; diff --git a/src/whatsapp/abstract/abstract.router.ts b/src/whatsapp/abstract/abstract.router.ts index 7c603880..18770ffa 100644 --- a/src/whatsapp/abstract/abstract.router.ts +++ b/src/whatsapp/abstract/abstract.router.ts @@ -21,7 +21,6 @@ const logger = new Logger('Validate'); export abstract class RouterBroker { constructor() {} public routerPath(path: string, param = true) { - // const route = param ? '/:instanceName/' + path : '/' + path; let route = '/' + path; param ? (route += '/:instanceName') : null; @@ -56,10 +55,6 @@ export abstract class RouterBroker { message = stack.replace('instance.', ''); } return message; - // return { - // property: property.replace('instance.', ''), - // message, - // }; }); logger.error(message); throw new BadRequestException(message); diff --git a/src/whatsapp/controllers/settings.controller.ts b/src/whatsapp/controllers/settings.controller.ts index 0f559d1b..15563647 100644 --- a/src/whatsapp/controllers/settings.controller.ts +++ b/src/whatsapp/controllers/settings.controller.ts @@ -1,7 +1,4 @@ -// import { isURL } from 'class-validator'; - import { Logger } from '../../config/logger.config'; -// import { BadRequestException } from '../../exceptions'; import { InstanceDto } from '../dto/instance.dto'; import { SettingsDto } from '../dto/settings.dto'; import { SettingsService } from '../services/settings.service'; diff --git a/src/whatsapp/routers/chatwoot.router.ts b/src/whatsapp/routers/chatwoot.router.ts index eb779587..c232e007 100644 --- a/src/whatsapp/routers/chatwoot.router.ts +++ b/src/whatsapp/routers/chatwoot.router.ts @@ -5,7 +5,6 @@ import { chatwootSchema, instanceNameSchema } from '../../validate/validate.sche import { RouterBroker } from '../abstract/abstract.router'; import { ChatwootDto } from '../dto/chatwoot.dto'; import { InstanceDto } from '../dto/instance.dto'; -// import { ChatwootService } from '../services/chatwoot.service'; import { chatwootController } from '../whatsapp.module'; import { HttpStatus } from './index.router'; diff --git a/src/whatsapp/routers/settings.router.ts b/src/whatsapp/routers/settings.router.ts index 6bd4d549..57e56b0d 100644 --- a/src/whatsapp/routers/settings.router.ts +++ b/src/whatsapp/routers/settings.router.ts @@ -5,7 +5,6 @@ import { instanceNameSchema, settingsSchema } from '../../validate/validate.sche import { RouterBroker } from '../abstract/abstract.router'; import { InstanceDto } from '../dto/instance.dto'; import { SettingsDto } from '../dto/settings.dto'; -// import { SettingsService } from '../services/settings.service'; import { settingsController } from '../whatsapp.module'; import { HttpStatus } from './index.router'; diff --git a/src/whatsapp/services/chatwoot.service.ts b/src/whatsapp/services/chatwoot.service.ts index 42043e65..b0b07ce5 100644 --- a/src/whatsapp/services/chatwoot.service.ts +++ b/src/whatsapp/services/chatwoot.service.ts @@ -51,11 +51,6 @@ export class ChatwootService { this.cache.set(cacheKey, provider); return provider; - // try { - // } catch (error) { - // this.logger.error('provider not found'); - // return null; - // } } private async clientCw(instance: InstanceDto) { @@ -389,10 +384,6 @@ export class ChatwootService { q: query, }); } else { - // contact = await client.contacts.filter({ - // accountId: this.provider.account_id, - // payload: this.getFilterPayload(query), - // }); // hotfix for: https://github.com/EvolutionAPI/evolution-api/pull/382. waiting fix: https://github.com/figurolatam/chatwoot-sdk/pull/7 contact = await chatwootRequest(this.getClientCwConfig(), { method: 'POST', @@ -1194,7 +1185,6 @@ export class ChatwootService { if (state !== 'open') { if (state === 'close') { this.logger.verbose('request cleaning up instance: ' + instance.instanceName); - // await this.waMonitor.cleaningUp(instance.instanceName); } this.logger.verbose('connect to whatsapp'); const number = command.split(':')[1];