mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-19 09:53:36 -06:00
Fix prettier errors
This commit is contained in:
parent
2816a16387
commit
0f2498bbaa
@ -10,7 +10,10 @@ import axios from 'axios';
|
|||||||
const logger = new Logger('ProxyController');
|
const logger = new Logger('ProxyController');
|
||||||
|
|
||||||
export class ProxyController {
|
export class ProxyController {
|
||||||
constructor(private readonly proxyService: ProxyService, private readonly waMonitor: WAMonitoringService) {}
|
constructor(
|
||||||
|
private readonly proxyService: ProxyService,
|
||||||
|
private readonly waMonitor: WAMonitoringService,
|
||||||
|
) {}
|
||||||
|
|
||||||
public async createProxy(instance: InstanceDto, data: ProxyDto) {
|
public async createProxy(instance: InstanceDto, data: ProxyDto) {
|
||||||
if (!this.waMonitor.waInstances[instance.instanceName]) {
|
if (!this.waMonitor.waInstances[instance.instanceName]) {
|
||||||
|
@ -24,7 +24,14 @@ export class InstanceDto extends IntegrationDto {
|
|||||||
proxyProtocol?: string;
|
proxyProtocol?: string;
|
||||||
proxyUsername?: string;
|
proxyUsername?: string;
|
||||||
proxyPassword?: string;
|
proxyPassword?: string;
|
||||||
webhook?: { enabled?: boolean; events?: string[]; headers?: JsonValue; url?: string; byEvents?: boolean; base64?: boolean; };
|
webhook?: {
|
||||||
|
enabled?: boolean;
|
||||||
|
events?: string[];
|
||||||
|
headers?: { [key: string]: string };
|
||||||
|
url?: string;
|
||||||
|
byEvents?: boolean;
|
||||||
|
base64?: boolean;
|
||||||
|
};
|
||||||
chatwootAccountId?: string;
|
chatwootAccountId?: string;
|
||||||
chatwootConversationPending?: boolean;
|
chatwootConversationPending?: boolean;
|
||||||
chatwootAutoCreate?: boolean;
|
chatwootAutoCreate?: boolean;
|
||||||
|
@ -330,13 +330,17 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
const buffer = await axios.get(result.data.url, { headers, responseType: 'arraybuffer' });
|
const buffer = await axios.get(result.data.url, { headers, responseType: 'arraybuffer' });
|
||||||
|
|
||||||
const mediaType = message.messages[0].document
|
let mediaType;
|
||||||
? 'document'
|
|
||||||
: message.messages[0].image
|
if (message.messages[0].document) {
|
||||||
? 'image'
|
mediaType = 'document';
|
||||||
: message.messages[0].audio
|
} else if (message.messages[0].image) {
|
||||||
? 'audio'
|
mediaType = 'image';
|
||||||
: 'video';
|
} else if (message.messages[0].audio) {
|
||||||
|
mediaType = 'audio';
|
||||||
|
} else {
|
||||||
|
mediaType = 'video';
|
||||||
|
}
|
||||||
|
|
||||||
const mimetype = result.data?.mime_type || result.headers['content-type'];
|
const mimetype = result.data?.mime_type || result.headers['content-type'];
|
||||||
|
|
||||||
@ -1100,11 +1104,10 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
if (file?.buffer) {
|
if (file?.buffer) {
|
||||||
mediaData.audio = file.buffer.toString('base64');
|
mediaData.audio = file.buffer.toString('base64');
|
||||||
}
|
} else if (isURL(mediaData.audio)) {
|
||||||
else if(isURL(mediaData.audio)){
|
// DO NOTHING
|
||||||
mediaData.audio = mediaData.audio
|
// mediaData.audio = mediaData.audio;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.error('El archivo no tiene buffer o file es undefined');
|
console.error('El archivo no tiene buffer o file es undefined');
|
||||||
throw new Error('File or buffer is undefined');
|
throw new Error('File or buffer is undefined');
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,10 @@ import { instanceSchema, webhookSchema } from '@validate/validate.schema';
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
export class WebhookRouter extends RouterBroker {
|
export class WebhookRouter extends RouterBroker {
|
||||||
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
|
constructor(
|
||||||
|
readonly configService: ConfigService,
|
||||||
|
...guards: RequestHandler[]
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
this.router
|
this.router
|
||||||
.post(this.routerPath('set'), ...guards, async (req, res) => {
|
.post(this.routerPath('set'), ...guards, async (req, res) => {
|
||||||
|
@ -8,7 +8,10 @@ import { RequestHandler, Router } from 'express';
|
|||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class InstanceRouter extends RouterBroker {
|
export class InstanceRouter extends RouterBroker {
|
||||||
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
|
constructor(
|
||||||
|
readonly configService: ConfigService,
|
||||||
|
...guards: RequestHandler[]
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
this.router
|
this.router
|
||||||
.post('/create', ...guards, async (req, res) => {
|
.post('/create', ...guards, async (req, res) => {
|
||||||
|
@ -9,7 +9,10 @@ import { RequestHandler, Router } from 'express';
|
|||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
export class TemplateRouter extends RouterBroker {
|
export class TemplateRouter extends RouterBroker {
|
||||||
constructor(readonly configService: ConfigService, ...guards: RequestHandler[]) {
|
constructor(
|
||||||
|
readonly configService: ConfigService,
|
||||||
|
...guards: RequestHandler[]
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
this.router
|
this.router
|
||||||
.post(this.routerPath('create'), ...guards, async (req, res) => {
|
.post(this.routerPath('create'), ...guards, async (req, res) => {
|
||||||
|
@ -42,7 +42,8 @@ export class WAMonitoringService {
|
|||||||
public delInstanceTime(instance: string) {
|
public delInstanceTime(instance: string) {
|
||||||
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
||||||
if (typeof time === 'number' && time > 0) {
|
if (typeof time === 'number' && time > 0) {
|
||||||
setTimeout(async () => {
|
setTimeout(
|
||||||
|
async () => {
|
||||||
if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
|
if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
|
||||||
if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
|
if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
|
||||||
if ((await this.waInstances[instance].integration) === Integration.WHATSAPP_BAILEYS) {
|
if ((await this.waInstances[instance].integration) === Integration.WHATSAPP_BAILEYS) {
|
||||||
@ -55,7 +56,9 @@ export class WAMonitoringService {
|
|||||||
this.eventEmitter.emit('remove.instance', instance, 'inner');
|
this.eventEmitter.emit('remove.instance', instance, 'inner');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1000 * 60 * time);
|
},
|
||||||
|
1000 * 60 * time,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +222,7 @@ export class WAMonitoringService {
|
|||||||
id: data.instanceId,
|
id: data.instanceId,
|
||||||
name: data.instanceName,
|
name: data.instanceName,
|
||||||
connectionStatus:
|
connectionStatus:
|
||||||
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : data.status ?? 'open',
|
data.integration && data.integration === Integration.WHATSAPP_BAILEYS ? 'close' : (data.status ?? 'open'),
|
||||||
number: data.number,
|
number: data.number,
|
||||||
integration: data.integration || Integration.WHATSAPP_BAILEYS,
|
integration: data.integration || Integration.WHATSAPP_BAILEYS,
|
||||||
token: data.hash,
|
token: data.hash,
|
||||||
|
5
src/cache/cacheengine.ts
vendored
5
src/cache/cacheengine.ts
vendored
@ -10,7 +10,10 @@ const logger = new Logger('CacheEngine');
|
|||||||
export class CacheEngine {
|
export class CacheEngine {
|
||||||
private engine: ICache;
|
private engine: ICache;
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService, module: string) {
|
constructor(
|
||||||
|
private readonly configService: ConfigService,
|
||||||
|
module: string,
|
||||||
|
) {
|
||||||
const cacheConf = configService.get<CacheConf>('CACHE');
|
const cacheConf = configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
if (cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') {
|
if (cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') {
|
||||||
|
5
src/cache/localcache.ts
vendored
5
src/cache/localcache.ts
vendored
@ -9,7 +9,10 @@ export class LocalCache implements ICache {
|
|||||||
private conf: CacheConfLocal;
|
private conf: CacheConfLocal;
|
||||||
static localCache = new NodeCache();
|
static localCache = new NodeCache();
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService, private readonly module: string) {
|
constructor(
|
||||||
|
private readonly configService: ConfigService,
|
||||||
|
private readonly module: string,
|
||||||
|
) {
|
||||||
this.conf = this.configService.get<CacheConf>('CACHE')?.LOCAL;
|
this.conf = this.configService.get<CacheConf>('CACHE')?.LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
src/cache/rediscache.ts
vendored
5
src/cache/rediscache.ts
vendored
@ -11,7 +11,10 @@ export class RedisCache implements ICache {
|
|||||||
private client: RedisClientType;
|
private client: RedisClientType;
|
||||||
private conf: CacheConfRedis;
|
private conf: CacheConfRedis;
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService, private readonly module: string) {
|
constructor(
|
||||||
|
private readonly configService: ConfigService,
|
||||||
|
private readonly module: string,
|
||||||
|
) {
|
||||||
this.conf = this.configService.get<CacheConf>('CACHE')?.REDIS;
|
this.conf = this.configService.get<CacheConf>('CACHE')?.REDIS;
|
||||||
this.client = redisClient.getConnection();
|
this.client = redisClient.getConnection();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user