Skip to content

Commit 0f2498b

Browse files
committed
Fix prettier errors
1 parent 2816a16 commit 0f2498b

File tree

11 files changed

+71
-37
lines changed

11 files changed

+71
-37
lines changed

src/api/controllers/proxy.controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import axios from 'axios';
1010
const logger = new Logger('ProxyController');
1111

1212
export class ProxyController {
13-
constructor(private readonly proxyService: ProxyService, private readonly waMonitor: WAMonitoringService) {}
13+
constructor(
14+
private readonly proxyService: ProxyService,
15+
private readonly waMonitor: WAMonitoringService,
16+
) {}
1417

1518
public async createProxy(instance: InstanceDto, data: ProxyDto) {
1619
if (!this.waMonitor.waInstances[instance.instanceName]) {

src/api/dto/instance.dto.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ export class InstanceDto extends IntegrationDto {
2424
proxyProtocol?: string;
2525
proxyUsername?: string;
2626
proxyPassword?: string;
27-
webhook?: { enabled?: boolean; events?: string[]; headers?: JsonValue; url?: string; byEvents?: boolean; base64?: boolean; };
27+
webhook?: {
28+
enabled?: boolean;
29+
events?: string[];
30+
headers?: { [key: string]: string };
31+
url?: string;
32+
byEvents?: boolean;
33+
base64?: boolean;
34+
};
2835
chatwootAccountId?: string;
2936
chatwootConversationPending?: boolean;
3037
chatwootAutoCreate?: boolean;

src/api/integrations/channel/meta/whatsapp.business.service.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,17 @@ export class BusinessStartupService extends ChannelStartupService {
330330

331331
const buffer = await axios.get(result.data.url, { headers, responseType: 'arraybuffer' });
332332

333-
const mediaType = message.messages[0].document
334-
? 'document'
335-
: message.messages[0].image
336-
? 'image'
337-
: message.messages[0].audio
338-
? 'audio'
339-
: 'video';
333+
let mediaType;
334+
335+
if (message.messages[0].document) {
336+
mediaType = 'document';
337+
} else if (message.messages[0].image) {
338+
mediaType = 'image';
339+
} else if (message.messages[0].audio) {
340+
mediaType = 'audio';
341+
} else {
342+
mediaType = 'video';
343+
}
340344

341345
const mimetype = result.data?.mime_type || result.headers['content-type'];
342346

@@ -797,7 +801,7 @@ export class BusinessStartupService extends ChannelStartupService {
797801
}
798802
if (message['media']) {
799803
const isImage = message['mimetype']?.startsWith('image/');
800-
804+
801805
content = {
802806
messaging_product: 'whatsapp',
803807
recipient_type: 'individual',
@@ -812,7 +816,7 @@ export class BusinessStartupService extends ChannelStartupService {
812816
};
813817
quoted ? (content.context = { message_id: quoted.id }) : content;
814818
return await this.post(content, 'messages');
815-
}
819+
}
816820
if (message['audio']) {
817821
content = {
818822
messaging_product: 'whatsapp',
@@ -1100,11 +1104,10 @@ export class BusinessStartupService extends ChannelStartupService {
11001104

11011105
if (file?.buffer) {
11021106
mediaData.audio = file.buffer.toString('base64');
1103-
}
1104-
else if(isURL(mediaData.audio)){
1105-
mediaData.audio = mediaData.audio
1106-
}
1107-
else {
1107+
} else if (isURL(mediaData.audio)) {
1108+
// DO NOTHING
1109+
// mediaData.audio = mediaData.audio;
1110+
} else {
11081111
console.error('El archivo no tiene buffer o file es undefined');
11091112
throw new Error('File or buffer is undefined');
11101113
}

src/api/integrations/event/webhook/webhook.router.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { instanceSchema, webhookSchema } from '@validate/validate.schema';
88
import { RequestHandler, Router } from 'express';
99

1010
export class WebhookRouter extends RouterBroker {
11-
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
11+
constructor(
12+
readonly configService: ConfigService,
13+
...guards: RequestHandler[]
14+
) {
1215
super();
1316
this.router
1417
.post(this.routerPath('set'), ...guards, async (req, res) => {

src/api/routes/instance.router.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { RequestHandler, Router } from 'express';
88
import { HttpStatus } from './index.router';
99

1010
export class InstanceRouter extends RouterBroker {
11-
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
11+
constructor(
12+
readonly configService: ConfigService,
13+
...guards: RequestHandler[]
14+
) {
1215
super();
1316
this.router
1417
.post('/create', ...guards, async (req, res) => {

src/api/routes/template.router.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { RequestHandler, Router } from 'express';
99
import { HttpStatus } from './index.router';
1010

1111
export class TemplateRouter extends RouterBroker {
12-
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
12+
constructor(
13+
readonly configService: ConfigService,
14+
...guards: RequestHandler[]
15+
) {
1316
super();
1417
this.router
1518
.post(this.routerPath('create'), ...guards, async (req, res) => {

src/api/services/monitor.service.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,23 @@ export class WAMonitoringService {
4242
public delInstanceTime(instance: string) {
4343
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
4444
if (typeof time === 'number' && time > 0) {
45-
setTimeout(async () => {
46-
if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
47-
if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
48-
if ((await this.waInstances[instance].integration) === Integration.WHATSAPP_BAILEYS) {
49-
await this.waInstances[instance]?.client?.logout('Log out instance: ' + instance);
50-
this.waInstances[instance]?.client?.ws?.close();
51-
this.waInstances[instance]?.client?.end(undefined);
45+
setTimeout(
46+
async () => {
47+
if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
48+
if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
49+
if ((await this.waInstances[instance].integration) === Integration.WHATSAPP_BAILEYS) {
50+
await this.waInstances[instance]?.client?.logout('Log out instance: ' + instance);
51+
this.waInstances[instance]?.client?.ws?.close();
52+
this.waInstances[instance]?.client?.end(undefined);
53+
}
54+
this.eventEmitter.emit('remove.instance', instance, 'inner');
55+
} else {
56+
this.eventEmitter.emit('remove.instance', instance, 'inner');
5257
}
53-
this.eventEmitter.emit('remove.instance', instance, 'inner');
54-
} else {
55-
this.eventEmitter.emit('remove.instance', instance, 'inner');
5658
}
57-
}
58-
}, 1000 * 60 * time);
59+
},
60+
1000 * 60 * time,
61+
);
5962
}
6063
}
6164

@@ -219,7 +222,7 @@ export class WAMonitoringService {
219222
id: data.instanceId,
220223
name: data.instanceName,
221224
connectionStatus:
222-
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : data.status ?? 'open',
225+
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : (data.status ?? 'open'),
223226
number: data.number,
224227
integration: data.integration || Integration.WHATSAPP_BAILEYS,
225228
token: data.hash,

src/cache/cacheengine.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const logger = new Logger('CacheEngine');
1010
export class CacheEngine {
1111
private engine: ICache;
1212

13-
constructor(private readonly configService: ConfigService, module: string) {
13+
constructor(
14+
private readonly configService: ConfigService,
15+
module: string,
16+
) {
1417
const cacheConf = configService.get<CacheConf>('CACHE');
1518

1619
if (cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') {

src/cache/localcache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export class LocalCache implements ICache {
99
private conf: CacheConfLocal;
1010
static localCache = new NodeCache();
1111

12-
constructor(private readonly configService: ConfigService, private readonly module: string) {
12+
constructor(
13+
private readonly configService: ConfigService,
14+
private readonly module: string,
15+
) {
1316
this.conf = this.configService.get<CacheConf>('CACHE')?.LOCAL;
1417
}
1518

src/cache/rediscache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export class RedisCache implements ICache {
1111
private client: RedisClientType;
1212
private conf: CacheConfRedis;
1313

14-
constructor(private readonly configService: ConfigService, private readonly module: string) {
14+
constructor(
15+
private readonly configService: ConfigService,
16+
private readonly module: string,
17+
) {
1518
this.conf = this.configService.get<CacheConf>('CACHE')?.REDIS;
1619
this.client = redisClient.getConnection();
1720
}

0 commit comments

Comments
 (0)