mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
wip
This commit is contained in:
parent
cc91f2e5db
commit
e151eb85f0
11
.eslintrc.js
11
.eslintrc.js
@ -3,10 +3,14 @@ module.exports = {
|
|||||||
parserOptions: {
|
parserOptions: {
|
||||||
sourceType: 'CommonJS',
|
sourceType: 'CommonJS',
|
||||||
},
|
},
|
||||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
plugins: [
|
||||||
|
'@typescript-eslint',
|
||||||
|
'simple-import-sort',
|
||||||
|
'import'
|
||||||
|
],
|
||||||
extends: [
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'plugin:prettier/recommended',
|
|
||||||
'plugin:prettier/recommended'
|
'plugin:prettier/recommended'
|
||||||
],
|
],
|
||||||
globals: {
|
globals: {
|
||||||
@ -27,6 +31,9 @@ module.exports = {
|
|||||||
'@typescript-eslint/no-empty-function': 'off',
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
'@typescript-eslint/no-unused-vars': 'off',
|
'@typescript-eslint/no-unused-vars': 'off',
|
||||||
|
'import/first': 'error',
|
||||||
|
'import/no-duplicates': 'error',
|
||||||
|
'simple-import-sort/imports': 'error',
|
||||||
'@typescript-eslint/ban-types': [
|
'@typescript-eslint/ban-types': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
|
13
package.json
13
package.json
@ -8,7 +8,8 @@
|
|||||||
"start": "ts-node --files --transpile-only ./src/main.ts",
|
"start": "ts-node --files --transpile-only ./src/main.ts",
|
||||||
"start:prod": "bash start.sh",
|
"start:prod": "bash start.sh",
|
||||||
"dev:server": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
|
"dev:server": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
|
||||||
"test": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts"
|
"test": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts",
|
||||||
|
"lint": "eslint --fix --ext .ts src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -84,12 +85,14 @@
|
|||||||
"@types/qrcode": "^1.5.0",
|
"@types/qrcode": "^1.5.0",
|
||||||
"@types/qrcode-terminal": "^0.12.0",
|
"@types/qrcode-terminal": "^0.12.0",
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
"@typescript-eslint/parser": "^5.57.1",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
"eslint": "^8.38.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"prettier": "^2.8.7",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
|
"prettier": "^2.8.8",
|
||||||
"ts-node-dev": "^2.0.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { isBooleanString } from 'class-validator';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { load } from 'js-yaml';
|
import { load } from 'js-yaml';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { isBooleanString } from 'class-validator';
|
|
||||||
|
|
||||||
export type HttpServer = { TYPE: 'http' | 'https'; PORT: number; URL: string };
|
export type HttpServer = { TYPE: 'http' | 'https'; PORT: number; URL: string };
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { configService, Log } from './env.config';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import { configService, Log } from './env.config';
|
||||||
|
|
||||||
const formatDateLog = (timestamp: number) =>
|
const formatDateLog = (timestamp: number) =>
|
||||||
dayjs(timestamp)
|
dayjs(timestamp)
|
||||||
.toDate()
|
.toDate()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
|
||||||
import { configService, Database } from '../config/env.config';
|
import { configService, Database } from '../config/env.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { createClient, RedisClientType } from '@redis/client';
|
import { createClient, RedisClientType } from '@redis/client';
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
import { BufferJSON } from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
import { Redis } from '../config/env.config';
|
import { Redis } from '../config/env.config';
|
||||||
|
import { Logger } from '../config/logger.config';
|
||||||
|
|
||||||
export class RedisCache {
|
export class RedisCache {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
12
src/main.ts
12
src/main.ts
@ -1,16 +1,18 @@
|
|||||||
|
import 'express-async-errors';
|
||||||
|
|
||||||
|
// import * as Sentry from '@sentry/node';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import { configService, Cors, HttpServer } from './config/env.config';
|
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { configService, Cors, HttpServer } from './config/env.config';
|
||||||
import { onUnexpectedError } from './config/error.config';
|
import { onUnexpectedError } from './config/error.config';
|
||||||
import { Logger } from './config/logger.config';
|
import { Logger } from './config/logger.config';
|
||||||
import { ROOT_DIR } from './config/path.config';
|
import { ROOT_DIR } from './config/path.config';
|
||||||
import { waMonitor } from './whatsapp/whatsapp.module';
|
|
||||||
import { HttpStatus, router } from './whatsapp/routers/index.router';
|
|
||||||
import 'express-async-errors';
|
|
||||||
import { ServerUP } from './utils/server-up';
|
import { ServerUP } from './utils/server-up';
|
||||||
import * as Sentry from '@sentry/node';
|
import { HttpStatus, router } from './whatsapp/routers/index.router';
|
||||||
|
import { waMonitor } from './whatsapp/whatsapp.module';
|
||||||
|
|
||||||
function initWA() {
|
function initWA() {
|
||||||
waMonitor.loadInstance();
|
waMonitor.loadInstance();
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Express } from 'express';
|
import { Express } from 'express';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { configService, SslConf } from '../config/env.config';
|
|
||||||
import * as https from 'https';
|
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
|
import * as https from 'https';
|
||||||
|
|
||||||
|
import { configService, SslConf } from '../config/env.config';
|
||||||
|
|
||||||
export class ServerUP {
|
export class ServerUP {
|
||||||
static #app: Express;
|
static #app: Express;
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
proto,
|
proto,
|
||||||
SignalDataTypeMap,
|
SignalDataTypeMap,
|
||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
import { configService, Database } from '../config/env.config';
|
import { configService, Database } from '../config/env.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
import { dbserver } from '../db/db.connect';
|
import { dbserver } from '../db/db.connect';
|
||||||
@ -29,7 +30,9 @@ export async function useMultiFileAuthStateDb(
|
|||||||
JSON.parse(JSON.stringify(data, BufferJSON.replacer)),
|
JSON.parse(JSON.stringify(data, BufferJSON.replacer)),
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
);
|
);
|
||||||
} catch {}
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const readData = async (key: string): Promise<any> => {
|
const readData = async (key: string): Promise<any> => {
|
||||||
@ -38,14 +41,18 @@ export async function useMultiFileAuthStateDb(
|
|||||||
const data = await collection.findOne({ _id: key });
|
const data = await collection.findOne({ _id: key });
|
||||||
const creds = JSON.stringify(data);
|
const creds = JSON.stringify(data);
|
||||||
return JSON.parse(creds, BufferJSON.reviver);
|
return JSON.parse(creds, BufferJSON.reviver);
|
||||||
} catch {}
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeData = async (key: string) => {
|
const removeData = async (key: string) => {
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
return await collection.deleteOne({ _id: key });
|
return await collection.deleteOne({ _id: key });
|
||||||
} catch {}
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const creds: AuthenticationCreds = (await readData('creds')) || initAuthCreds();
|
const creds: AuthenticationCreds = (await readData('creds')) || initAuthCreds();
|
||||||
|
@ -5,9 +5,10 @@ import {
|
|||||||
proto,
|
proto,
|
||||||
SignalDataTypeMap,
|
SignalDataTypeMap,
|
||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
import { RedisCache } from '../db/redis.client';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
import { Redis } from '../config/env.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<{
|
export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
|
||||||
state: AuthenticationState;
|
state: AuthenticationState;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { ConfigService, Database } from '../../config/env.config';
|
import { ConfigService, Database } from '../../config/env.config';
|
||||||
import { ROOT_DIR } from '../../config/path.config';
|
import { ROOT_DIR } from '../../config/path.config';
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { JSONSchema7 } from 'json-schema';
|
|
||||||
import { Request } from 'express';
|
|
||||||
import { validate } from 'jsonschema';
|
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import 'express-async-errors';
|
import 'express-async-errors';
|
||||||
|
|
||||||
|
import { Request } from 'express';
|
||||||
|
import { JSONSchema7 } from 'json-schema';
|
||||||
|
import { validate } from 'jsonschema';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { BadRequestException } from '../../exceptions';
|
||||||
import { GetParticipant, GroupInvite, GroupJid } from '../dto/group.dto';
|
import { GetParticipant, GroupInvite, GroupJid } from '../dto/group.dto';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
|
|
||||||
type DataValidate<T> = {
|
type DataValidate<T> = {
|
||||||
request: Request;
|
request: Request;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import { proto } from '@whiskeysockets/baileys';
|
import { proto } from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import {
|
import {
|
||||||
ArchiveChatDto,
|
ArchiveChatDto,
|
||||||
DeleteMessage,
|
DeleteMessage,
|
||||||
|
getBase64FromMediaMessageDto,
|
||||||
NumberDto,
|
NumberDto,
|
||||||
PrivacySettingDto,
|
PrivacySettingDto,
|
||||||
ProfileNameDto,
|
ProfileNameDto,
|
||||||
@ -9,14 +12,12 @@ import {
|
|||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
getBase64FromMediaMessageDto,
|
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { ContactQuery } from '../repository/contact.repository';
|
import { ContactQuery } from '../repository/contact.repository';
|
||||||
import { MessageQuery } from '../repository/message.repository';
|
import { MessageQuery } from '../repository/message.repository';
|
||||||
import { MessageUpQuery } from '../repository/messageUp.repository';
|
import { MessageUpQuery } from '../repository/messageUp.repository';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '../services/monitor.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('ChatController');
|
const logger = new Logger('ChatController');
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
|
||||||
import { ChatwootService } from '../services/chatwoot.service';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { waMonitor } from '../whatsapp.module';
|
|
||||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { BadRequestException } from '../../exceptions';
|
||||||
|
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
|
import { ChatwootService } from '../services/chatwoot.service';
|
||||||
|
import { waMonitor } from '../whatsapp.module';
|
||||||
|
|
||||||
const logger = new Logger('ChatwootController');
|
const logger = new Logger('ChatwootController');
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import {
|
import {
|
||||||
CreateGroupDto,
|
CreateGroupDto,
|
||||||
GetParticipant,
|
GetParticipant,
|
||||||
@ -13,7 +14,6 @@ import {
|
|||||||
} from '../dto/group.dto';
|
} from '../dto/group.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '../services/monitor.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('ChatController');
|
const logger = new Logger('ChatController');
|
||||||
|
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import { delay } from '@whiskeysockets/baileys';
|
import { delay } from '@whiskeysockets/baileys';
|
||||||
|
import { isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
|
|
||||||
import { Auth, ConfigService, HttpServer } from '../../config/env.config';
|
import { Auth, ConfigService, HttpServer } from '../../config/env.config';
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { RedisCache } from '../../db/redis.client';
|
||||||
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
import { AuthService, OldToken } from '../services/auth.service';
|
import { AuthService, OldToken } from '../services/auth.service';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
|
||||||
import { WAStartupService } from '../services/whatsapp.service';
|
|
||||||
import { WebhookService } from '../services/webhook.service';
|
|
||||||
import { ChatwootService } from '../services/chatwoot.service';
|
import { ChatwootService } from '../services/chatwoot.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { WAMonitoringService } from '../services/monitor.service';
|
||||||
|
import { WebhookService } from '../services/webhook.service';
|
||||||
|
import { WAStartupService } from '../services/whatsapp.service';
|
||||||
import { wa } from '../types/wa.types';
|
import { wa } from '../types/wa.types';
|
||||||
import { RedisCache } from '../../db/redis.client';
|
|
||||||
import { isURL } from 'class-validator';
|
|
||||||
|
|
||||||
export class InstanceController {
|
export class InstanceController {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { isBase64, isURL } from 'class-validator';
|
import { isBase64, isURL } from 'class-validator';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { BadRequestException } from '../../exceptions';
|
import { BadRequestException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import {
|
import {
|
||||||
@ -16,8 +18,6 @@ import {
|
|||||||
} from '../dto/sendMessage.dto';
|
} from '../dto/sendMessage.dto';
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
import { WAMonitoringService } from '../services/monitor.service';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('MessageRouter');
|
const logger = new Logger('MessageRouter');
|
||||||
|
|
||||||
export class SendMessageController {
|
export class SendMessageController {
|
||||||
@ -109,7 +109,7 @@ export class SendMessageController {
|
|||||||
|
|
||||||
public async sendReaction({ instanceName }: InstanceDto, data: SendReactionDto) {
|
public async sendReaction({ instanceName }: InstanceDto, data: SendReactionDto) {
|
||||||
logger.verbose('requested sendReaction from ' + instanceName + ' instance');
|
logger.verbose('requested sendReaction from ' + instanceName + ' instance');
|
||||||
if (!data.reactionMessage.reaction.match(/[^\(\)\w\sà-ú"-\+]+/)) {
|
if (!data.reactionMessage.reaction.match(/[^()\w\sà-ú"-+]+/)) {
|
||||||
throw new BadRequestException('"reaction" must be an emoji');
|
throw new BadRequestException('"reaction" must be an emoji');
|
||||||
}
|
}
|
||||||
return await this.waMonitor.waInstances[instanceName].reactionMessage(data);
|
return await this.waMonitor.waInstances[instanceName].reactionMessage(data);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { BadRequestException } from '../../exceptions';
|
import { BadRequestException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
import { SettingsDto } from '../dto/settings.dto';
|
||||||
import { SettingsService } from '../services/settings.service';
|
import { SettingsService } from '../services/settings.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('SettingsController');
|
const logger = new Logger('SettingsController');
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
|
|
||||||
import { Auth, ConfigService } from '../../config/env.config';
|
import { Auth, ConfigService } from '../../config/env.config';
|
||||||
import { BadRequestException } from '../../exceptions';
|
import { BadRequestException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { BadRequestException } from '../../exceptions';
|
import { BadRequestException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
import { WebhookDto } from '../dto/webhook.dto';
|
||||||
import { WebhookService } from '../services/webhook.service';
|
import { WebhookService } from '../services/webhook.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('WebhookController');
|
const logger = new Logger('WebhookController');
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
|
proto,
|
||||||
WAPrivacyOnlineValue,
|
WAPrivacyOnlineValue,
|
||||||
WAPrivacyValue,
|
WAPrivacyValue,
|
||||||
WAReadReceiptsValue,
|
WAReadReceiptsValue,
|
||||||
proto,
|
|
||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
export class OnWhatsAppDto {
|
export class OnWhatsAppDto {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { isJWT } from 'class-validator';
|
import { isJWT } from 'class-validator';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
import { name } from '../../../package.json';
|
||||||
import { Auth, configService } from '../../config/env.config';
|
import { Auth, configService } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { name } from '../../../package.json';
|
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { JwtPayload } from '../services/auth.service';
|
import { JwtPayload } from '../services/auth.service';
|
||||||
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
|
||||||
import { repository } from '../whatsapp.module';
|
import { repository } from '../whatsapp.module';
|
||||||
|
|
||||||
const logger = new Logger('GUARD');
|
const logger = new Logger('GUARD');
|
||||||
@ -86,7 +87,9 @@ async function apikey(req: Request, res: Response, next: NextFunction) {
|
|||||||
if (instanceKey.apikey === key) {
|
if (instanceKey.apikey === key) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { configService, Database, Redis } from '../../config/env.config';
|
||||||
import { INSTANCE_DIR } from '../../config/path.config';
|
import { INSTANCE_DIR } from '../../config/path.config';
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
import {
|
import {
|
||||||
@ -10,7 +12,6 @@ import {
|
|||||||
} from '../../exceptions';
|
} from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { cache, waMonitor } from '../whatsapp.module';
|
import { cache, waMonitor } from '../whatsapp.module';
|
||||||
import { Database, Redis, configService } from '../../config/env.config';
|
|
||||||
|
|
||||||
async function getInstance(instanceName: string) {
|
async function getInstance(instanceName: string) {
|
||||||
const db = configService.get<Database>('DATABASE');
|
const db = configService.get<Database>('DATABASE');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class AuthRaw {
|
export class AuthRaw {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class ChatRaw {
|
export class ChatRaw {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class ChatwootRaw {
|
export class ChatwootRaw {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class ContactRaw {
|
export class ContactRaw {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
import { wa } from '../types/wa.types';
|
import { wa } from '../types/wa.types';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class SettingsRaw {
|
export class SettingsRaw {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from 'mongoose';
|
import { Schema } from 'mongoose';
|
||||||
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
|
||||||
export class WebhookRaw {
|
export class WebhookRaw {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { join } from 'path';
|
|
||||||
import { Auth, ConfigService, Database } from '../../config/env.config';
|
|
||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { IAuthModel, AuthRaw } from '../models';
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { AUTH_DIR } from '../../config/path.config';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { Auth, ConfigService, Database } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { AUTH_DIR } from '../../config/path.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { AuthRaw, IAuthModel } from '../models';
|
||||||
|
|
||||||
export class AuthRepository extends Repository {
|
export class AuthRepository extends Repository {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { join } from 'path';
|
|
||||||
import { ConfigService, StoreConf } from '../../config/env.config';
|
|
||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { opendirSync, readFileSync, rmSync } from 'fs';
|
import { opendirSync, readFileSync, rmSync } from 'fs';
|
||||||
import { ChatRaw, IChatModel } from '../models';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService, StoreConf } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { ChatRaw, IChatModel } from '../models';
|
||||||
|
|
||||||
export class ChatQuery {
|
export class ChatQuery {
|
||||||
where: ChatRaw;
|
where: ChatRaw;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { IChatwootModel, ChatwootRaw } from '../models';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { ChatwootRaw, IChatwootModel } from '../models';
|
||||||
|
|
||||||
export class ChatwootRepository extends Repository {
|
export class ChatwootRepository extends Repository {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { opendirSync, readFileSync } from 'fs';
|
import { opendirSync, readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { ConfigService, StoreConf } from '../../config/env.config';
|
import { ConfigService, StoreConf } from '../../config/env.config';
|
||||||
import { ContactRaw, IContactModel } from '../models';
|
|
||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { ContactRaw, IContactModel } from '../models';
|
||||||
|
|
||||||
export class ContactQuery {
|
export class ContactQuery {
|
||||||
where: ContactRaw;
|
where: ContactRaw;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { ConfigService, StoreConf } from '../../config/env.config';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { IMessageModel, MessageRaw } from '../models';
|
|
||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { opendirSync, readFileSync } from 'fs';
|
import { opendirSync, readFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService, StoreConf } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { IMessageModel, MessageRaw } from '../models';
|
||||||
|
|
||||||
export class MessageQuery {
|
export class MessageQuery {
|
||||||
where: MessageRaw;
|
where: MessageRaw;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { ConfigService, StoreConf } from '../../config/env.config';
|
|
||||||
import { IMessageUpModel, MessageUpdateRaw } from '../models';
|
|
||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { opendirSync, readFileSync } from 'fs';
|
import { opendirSync, readFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService, StoreConf } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { IMessageUpModel, MessageUpdateRaw } from '../models';
|
||||||
|
|
||||||
export class MessageUpQuery {
|
export class MessageUpQuery {
|
||||||
where: MessageUpdateRaw;
|
where: MessageUpdateRaw;
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { MessageRepository } from './message.repository';
|
|
||||||
import { ChatRepository } from './chat.repository';
|
|
||||||
import { ContactRepository } from './contact.repository';
|
|
||||||
import { MessageUpRepository } from './messageUp.repository';
|
|
||||||
import { MongoClient } from 'mongodb';
|
|
||||||
import { WebhookRepository } from './webhook.repository';
|
|
||||||
import { ChatwootRepository } from './chatwoot.repository';
|
|
||||||
import { SettingsRepository } from './settings.repository';
|
|
||||||
|
|
||||||
import { AuthRepository } from './auth.repository';
|
|
||||||
import { Auth, ConfigService, Database } from '../../config/env.config';
|
|
||||||
import { join } from 'path';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import { MongoClient } from 'mongodb';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { Auth, ConfigService, Database } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { AuthRepository } from './auth.repository';
|
||||||
|
import { ChatRepository } from './chat.repository';
|
||||||
|
import { ChatwootRepository } from './chatwoot.repository';
|
||||||
|
import { ContactRepository } from './contact.repository';
|
||||||
|
import { MessageRepository } from './message.repository';
|
||||||
|
import { MessageUpRepository } from './messageUp.repository';
|
||||||
|
import { SettingsRepository } from './settings.repository';
|
||||||
|
import { WebhookRepository } from './webhook.repository';
|
||||||
export class RepositoryBroker {
|
export class RepositoryBroker {
|
||||||
constructor(
|
constructor(
|
||||||
public readonly message: MessageRepository,
|
public readonly message: MessageRepository,
|
||||||
@ -97,6 +97,7 @@ export class RepositoryBroker {
|
|||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
const storePath = join(process.cwd(), 'store');
|
const storePath = join(process.cwd(), 'store');
|
||||||
|
|
||||||
this.logger.verbose('creating store path: ' + storePath);
|
this.logger.verbose('creating store path: ' + storePath);
|
||||||
@ -107,7 +108,6 @@ export class RepositoryBroker {
|
|||||||
this.logger.verbose('creating temp dir: ' + tempDir);
|
this.logger.verbose('creating temp dir: ' + tempDir);
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { ISettingsModel, SettingsRaw } from '../models';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { ISettingsModel, SettingsRaw } from '../models';
|
||||||
|
|
||||||
export class SettingsRepository extends Repository {
|
export class SettingsRepository extends Repository {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { IWebhookModel, WebhookRaw } from '../models';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { ConfigService } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||||
|
import { IWebhookModel, WebhookRaw } from '../models';
|
||||||
|
|
||||||
export class WebhookRepository extends Repository {
|
export class WebhookRepository extends Repository {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import { proto } from '@whiskeysockets/baileys';
|
||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import {
|
import {
|
||||||
archiveChatSchema,
|
archiveChatSchema,
|
||||||
contactValidateSchema,
|
contactValidateSchema,
|
||||||
@ -13,9 +16,11 @@ import {
|
|||||||
readMessageSchema,
|
readMessageSchema,
|
||||||
whatsappNumberSchema,
|
whatsappNumberSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import {
|
import {
|
||||||
ArchiveChatDto,
|
ArchiveChatDto,
|
||||||
DeleteMessage,
|
DeleteMessage,
|
||||||
|
getBase64FromMediaMessageDto,
|
||||||
NumberDto,
|
NumberDto,
|
||||||
PrivacySettingDto,
|
PrivacySettingDto,
|
||||||
ProfileNameDto,
|
ProfileNameDto,
|
||||||
@ -23,17 +28,13 @@ import {
|
|||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
getBase64FromMediaMessageDto,
|
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { ContactQuery } from '../repository/contact.repository';
|
import { ContactQuery } from '../repository/contact.repository';
|
||||||
import { MessageQuery } from '../repository/message.repository';
|
import { MessageQuery } from '../repository/message.repository';
|
||||||
import { chatController } from '../whatsapp.module';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { HttpStatus } from './index.router';
|
|
||||||
import { MessageUpQuery } from '../repository/messageUp.repository';
|
import { MessageUpQuery } from '../repository/messageUp.repository';
|
||||||
import { proto } from '@whiskeysockets/baileys';
|
import { chatController } from '../whatsapp.module';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { HttpStatus } from './index.router';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('ChatRouter');
|
const logger = new Logger('ChatRouter');
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
import { instanceNameSchema, chatwootSchema } from '../../validate/validate.schema';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
|
||||||
import { chatwootController } from '../whatsapp.module';
|
|
||||||
import { ChatwootService } from '../services/chatwoot.service';
|
|
||||||
import { HttpStatus } from './index.router';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { chatwootSchema, instanceNameSchema } from '../../validate/validate.schema';
|
||||||
|
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';
|
||||||
|
|
||||||
const logger = new Logger('ChatwootRouter');
|
const logger = new Logger('ChatwootRouter');
|
||||||
|
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import {
|
import {
|
||||||
createGroupSchema,
|
createGroupSchema,
|
||||||
|
getParticipantsSchema,
|
||||||
|
groupInviteSchema,
|
||||||
groupJidSchema,
|
groupJidSchema,
|
||||||
updateParticipantsSchema,
|
groupSendInviteSchema,
|
||||||
updateSettingsSchema,
|
|
||||||
toggleEphemeralSchema,
|
toggleEphemeralSchema,
|
||||||
|
updateGroupDescriptionSchema,
|
||||||
updateGroupPictureSchema,
|
updateGroupPictureSchema,
|
||||||
updateGroupSubjectSchema,
|
updateGroupSubjectSchema,
|
||||||
updateGroupDescriptionSchema,
|
updateParticipantsSchema,
|
||||||
groupInviteSchema,
|
updateSettingsSchema,
|
||||||
groupSendInviteSchema,
|
|
||||||
getParticipantsSchema,
|
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import {
|
import {
|
||||||
CreateGroupDto,
|
CreateGroupDto,
|
||||||
|
GetParticipant,
|
||||||
|
GroupDescriptionDto,
|
||||||
GroupInvite,
|
GroupInvite,
|
||||||
GroupJid,
|
GroupJid,
|
||||||
GroupPictureDto,
|
GroupPictureDto,
|
||||||
|
GroupSendInvite,
|
||||||
GroupSubjectDto,
|
GroupSubjectDto,
|
||||||
GroupDescriptionDto,
|
GroupToggleEphemeralDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
GroupToggleEphemeralDto,
|
|
||||||
GroupSendInvite,
|
|
||||||
GetParticipant,
|
|
||||||
} from '../dto/group.dto';
|
} from '../dto/group.dto';
|
||||||
import { groupController } from '../whatsapp.module';
|
import { groupController } from '../whatsapp.module';
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('GroupRouter');
|
const logger = new Logger('GroupRouter');
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
import { Auth, configService } from '../../config/env.config';
|
import { Auth, configService } from '../../config/env.config';
|
||||||
import { instanceExistsGuard, instanceLoggedGuard } from '../guards/instance.guard';
|
|
||||||
import { authGuard } from '../guards/auth.guard';
|
import { authGuard } from '../guards/auth.guard';
|
||||||
|
import { instanceExistsGuard, instanceLoggedGuard } from '../guards/instance.guard';
|
||||||
import { ChatRouter } from './chat.router';
|
import { ChatRouter } from './chat.router';
|
||||||
|
import { ChatwootRouter } from './chatwoot.router';
|
||||||
import { GroupRouter } from './group.router';
|
import { GroupRouter } from './group.router';
|
||||||
import { InstanceRouter } from './instance.router';
|
import { InstanceRouter } from './instance.router';
|
||||||
import { MessageRouter } from './sendMessage.router';
|
import { MessageRouter } from './sendMessage.router';
|
||||||
|
import { SettingsRouter } from './settings.router';
|
||||||
import { ViewsRouter } from './view.router';
|
import { ViewsRouter } from './view.router';
|
||||||
import { WebhookRouter } from './webhook.router';
|
import { WebhookRouter } from './webhook.router';
|
||||||
import { ChatwootRouter } from './chatwoot.router';
|
|
||||||
import fs from 'fs';
|
|
||||||
import { SettingsRouter } from './settings.router';
|
|
||||||
|
|
||||||
enum HttpStatus {
|
enum HttpStatus {
|
||||||
OK = 200,
|
OK = 200,
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
import { instanceNameSchema, oldTokenSchema } from '../../validate/validate.schema';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { instanceController } from '../whatsapp.module';
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { HttpStatus } from './index.router';
|
|
||||||
import { OldToken } from '../services/auth.service';
|
|
||||||
import { Auth, ConfigService, Database } from '../../config/env.config';
|
import { Auth, ConfigService, Database } from '../../config/env.config';
|
||||||
import { dbserver } from '../../db/db.connect';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { dbserver } from '../../db/db.connect';
|
||||||
|
import { instanceNameSchema, oldTokenSchema } from '../../validate/validate.schema';
|
||||||
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
|
import { OldToken } from '../services/auth.service';
|
||||||
|
import { instanceController } from '../whatsapp.module';
|
||||||
|
import { HttpStatus } from './index.router';
|
||||||
|
|
||||||
const logger = new Logger('InstanceRouter');
|
const logger = new Logger('InstanceRouter');
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import {
|
import {
|
||||||
audioMessageSchema,
|
audioMessageSchema,
|
||||||
buttonMessageSchema,
|
buttonMessageSchema,
|
||||||
@ -12,6 +14,7 @@ import {
|
|||||||
stickerMessageSchema,
|
stickerMessageSchema,
|
||||||
textMessageSchema,
|
textMessageSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import {
|
import {
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
SendButtonDto,
|
||||||
@ -26,9 +29,7 @@ import {
|
|||||||
SendTextDto,
|
SendTextDto,
|
||||||
} from '../dto/sendMessage.dto';
|
} from '../dto/sendMessage.dto';
|
||||||
import { sendMessageController } from '../whatsapp.module';
|
import { sendMessageController } from '../whatsapp.module';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('MessageRouter');
|
const logger = new Logger('MessageRouter');
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { instanceNameSchema, settingsSchema } from '../../validate/validate.schema';
|
import { instanceNameSchema, settingsSchema } from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
import { SettingsDto } from '../dto/settings.dto';
|
||||||
import { settingsController } from '../whatsapp.module';
|
|
||||||
import { SettingsService } from '../services/settings.service';
|
import { SettingsService } from '../services/settings.service';
|
||||||
|
import { settingsController } from '../whatsapp.module';
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('SettingsRouter');
|
const logger = new Logger('SettingsRouter');
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import { viewsController } from '../whatsapp.module';
|
import { viewsController } from '../whatsapp.module';
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { RequestHandler, Router } from 'express';
|
import { RequestHandler, Router } from 'express';
|
||||||
|
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { instanceNameSchema, webhookSchema } from '../../validate/validate.schema';
|
import { instanceNameSchema, webhookSchema } from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
import { WebhookDto } from '../dto/webhook.dto';
|
||||||
import { webhookController } from '../whatsapp.module';
|
import { webhookController } from '../whatsapp.module';
|
||||||
import { HttpStatus } from './index.router';
|
import { HttpStatus } from './index.router';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
const logger = new Logger('WebhookRouter');
|
const logger = new Logger('WebhookRouter');
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import { Auth, ConfigService, Webhook } from '../../config/env.config';
|
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import { name as apiName } from '../../../package.json';
|
|
||||||
import { verify, sign } from 'jsonwebtoken';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import { v4 } from 'uuid';
|
|
||||||
import { isJWT } from 'class-validator';
|
|
||||||
import { BadRequestException } from '../../exceptions';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { isJWT } from 'class-validator';
|
||||||
|
import { sign, verify } from 'jsonwebtoken';
|
||||||
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
|
import { name as apiName } from '../../../package.json';
|
||||||
|
import { Auth, ConfigService, Webhook } from '../../config/env.config';
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { BadRequestException } from '../../exceptions';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export type JwtPayload = {
|
export type JwtPayload = {
|
||||||
instanceName: string;
|
instanceName: string;
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
import { InstanceDto } from '../dto/instance.dto';
|
|
||||||
import path from 'path';
|
|
||||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
|
||||||
import { WAMonitoringService } from './monitor.service';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import ChatwootClient from '@figuro/chatwoot-sdk';
|
import ChatwootClient from '@figuro/chatwoot-sdk';
|
||||||
import { createReadStream, readFileSync, unlinkSync, writeFileSync } from 'fs';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import { SendTextDto } from '../dto/sendMessage.dto';
|
import { createReadStream, readFileSync, unlinkSync, writeFileSync } from 'fs';
|
||||||
import mimeTypes from 'mime-types';
|
import mimeTypes from 'mime-types';
|
||||||
import { SendAudioDto } from '../dto/sendMessage.dto';
|
import path from 'path';
|
||||||
import { SendMediaDto } from '../dto/sendMessage.dto';
|
|
||||||
import { ROOT_DIR } from '../../config/path.config';
|
|
||||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
|
import { ROOT_DIR } from '../../config/path.config';
|
||||||
|
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||||
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
|
import { SendAudioDto, SendMediaDto, SendTextDto } from '../dto/sendMessage.dto';
|
||||||
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class ChatwootService {
|
export class ChatwootService {
|
||||||
private messageCacheFile: string;
|
private messageCacheFile: string;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { opendirSync, readdirSync, rmSync } from 'fs';
|
import { execSync } from 'child_process';
|
||||||
import { WAStartupService } from './whatsapp.service';
|
|
||||||
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
|
import { opendirSync, readdirSync, rmSync } from 'fs';
|
||||||
|
import { Db } from 'mongodb';
|
||||||
|
import mongoose from 'mongoose';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
import {
|
import {
|
||||||
Auth,
|
Auth,
|
||||||
ConfigService,
|
ConfigService,
|
||||||
@ -12,13 +13,11 @@ import {
|
|||||||
HttpServer,
|
HttpServer,
|
||||||
Redis,
|
Redis,
|
||||||
} from '../../config/env.config';
|
} from '../../config/env.config';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { NotFoundException } from '../../exceptions';
|
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
||||||
import { Db } from 'mongodb';
|
|
||||||
import { RedisCache } from '../../db/redis.client';
|
|
||||||
import { execSync } from 'child_process';
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
import mongoose from 'mongoose';
|
import { RedisCache } from '../../db/redis.client';
|
||||||
|
import { NotFoundException } from '../../exceptions';
|
||||||
import {
|
import {
|
||||||
AuthModel,
|
AuthModel,
|
||||||
ChatwootModel,
|
ChatwootModel,
|
||||||
@ -28,6 +27,8 @@ import {
|
|||||||
SettingsModel,
|
SettingsModel,
|
||||||
WebhookModel,
|
WebhookModel,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
|
import { WAStartupService } from './whatsapp.service';
|
||||||
|
|
||||||
export class WAMonitoringService {
|
export class WAMonitoringService {
|
||||||
constructor(
|
constructor(
|
||||||
@ -183,7 +184,7 @@ export class WAMonitoringService {
|
|||||||
});
|
});
|
||||||
this.logger.verbose('instance files deleted: ' + name);
|
this.logger.verbose('instance files deleted: ' + name);
|
||||||
});
|
});
|
||||||
} else if (this.redis.ENABLED) {
|
// } else if (this.redis.ENABLED) {
|
||||||
} else {
|
} else {
|
||||||
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
||||||
for await (const dirent of dir) {
|
for await (const dirent of dir) {
|
||||||
@ -337,7 +338,9 @@ export class WAMonitoringService {
|
|||||||
try {
|
try {
|
||||||
this.logger.verbose('instance: ' + instanceName + ' - removing from memory');
|
this.logger.verbose('instance: ' + instanceName + ' - removing from memory');
|
||||||
this.waInstances[instanceName] = undefined;
|
this.waInstances[instanceName] = undefined;
|
||||||
} catch {}
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.logger.verbose('request cleaning up instance: ' + instanceName);
|
this.logger.verbose('request cleaning up instance: ' + instanceName);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { SettingsDto } from '../dto/settings.dto';
|
import { SettingsDto } from '../dto/settings.dto';
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { WebhookDto } from '../dto/webhook.dto';
|
import { WebhookDto } from '../dto/webhook.dto';
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
import { Logger } from '../../config/logger.config';
|
|
||||||
|
|
||||||
export class WebhookService {
|
export class WebhookService {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||||
|
import { Boom } from '@hapi/boom';
|
||||||
import makeWASocket, {
|
import makeWASocket, {
|
||||||
AnyMessageContent,
|
AnyMessageContent,
|
||||||
BufferedEventData,
|
BufferedEventData,
|
||||||
BufferJSON,
|
BufferJSON,
|
||||||
CacheStore,
|
CacheStore,
|
||||||
makeCacheableSignalKeyStore,
|
|
||||||
Chat,
|
Chat,
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
Contact,
|
Contact,
|
||||||
@ -12,11 +13,13 @@ import makeWASocket, {
|
|||||||
downloadMediaMessage,
|
downloadMediaMessage,
|
||||||
fetchLatestBaileysVersion,
|
fetchLatestBaileysVersion,
|
||||||
generateWAMessageFromContent,
|
generateWAMessageFromContent,
|
||||||
|
getAggregateVotesInPollMessage,
|
||||||
getContentType,
|
getContentType,
|
||||||
getDevice,
|
getDevice,
|
||||||
GroupMetadata,
|
GroupMetadata,
|
||||||
isJidGroup,
|
isJidGroup,
|
||||||
isJidUser,
|
isJidUser,
|
||||||
|
makeCacheableSignalKeyStore,
|
||||||
MessageUpsertType,
|
MessageUpsertType,
|
||||||
MiscMessageGenerationOptions,
|
MiscMessageGenerationOptions,
|
||||||
ParticipantAction,
|
ParticipantAction,
|
||||||
@ -29,8 +32,24 @@ import makeWASocket, {
|
|||||||
WAMessage,
|
WAMessage,
|
||||||
WAMessageUpdate,
|
WAMessageUpdate,
|
||||||
WASocket,
|
WASocket,
|
||||||
getAggregateVotesInPollMessage,
|
|
||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { exec, execSync } from 'child_process';
|
||||||
|
import { arrayUnique, isBase64, isURL } from 'class-validator';
|
||||||
|
import EventEmitter2 from 'eventemitter2';
|
||||||
|
import fs, { existsSync, readFileSync } from 'fs';
|
||||||
|
import Long from 'long';
|
||||||
|
import NodeCache from 'node-cache';
|
||||||
|
import { getMIMEType } from 'node-mime-types';
|
||||||
|
import { release } from 'os';
|
||||||
|
import { join } from 'path';
|
||||||
|
import P from 'pino';
|
||||||
|
import ProxyAgent from 'proxy-agent';
|
||||||
|
import qrcode, { QRCodeToDataURLOptions } from 'qrcode';
|
||||||
|
import qrcodeTerminal from 'qrcode-terminal';
|
||||||
|
import sharp from 'sharp';
|
||||||
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Auth,
|
Auth,
|
||||||
CleanStoreConf,
|
CleanStoreConf,
|
||||||
@ -38,31 +57,45 @@ import {
|
|||||||
ConfigSessionPhone,
|
ConfigSessionPhone,
|
||||||
Database,
|
Database,
|
||||||
HttpServer,
|
HttpServer,
|
||||||
|
Log,
|
||||||
QrCode,
|
QrCode,
|
||||||
Redis,
|
Redis,
|
||||||
Webhook,
|
Webhook,
|
||||||
} from '../../config/env.config';
|
} from '../../config/env.config';
|
||||||
import fs from 'fs';
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { INSTANCE_DIR, ROOT_DIR } from '../../config/path.config';
|
import { INSTANCE_DIR, ROOT_DIR } from '../../config/path.config';
|
||||||
import { existsSync, readFileSync } from 'fs';
|
import { dbserver } from '../../db/db.connect';
|
||||||
import { join } from 'path';
|
import { RedisCache } from '../../db/redis.client';
|
||||||
import axios from 'axios';
|
import {
|
||||||
import { v4 } from 'uuid';
|
BadRequestException,
|
||||||
import qrcode, { QRCodeToDataURLOptions } from 'qrcode';
|
InternalServerErrorException,
|
||||||
import qrcodeTerminal from 'qrcode-terminal';
|
NotFoundException,
|
||||||
import { Events, TypeMediaMessage, wa, MessageSubtype } from '../types/wa.types';
|
} from '../../exceptions';
|
||||||
import { Boom } from '@hapi/boom';
|
import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-db';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-state-redis-db';
|
||||||
import { release } from 'os';
|
import {
|
||||||
import P from 'pino';
|
ArchiveChatDto,
|
||||||
import { execSync, exec } from 'child_process';
|
DeleteMessage,
|
||||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
getBase64FromMediaMessageDto,
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
NumberBusiness,
|
||||||
import { MessageRaw, MessageUpdateRaw } from '../models/message.model';
|
OnWhatsAppDto,
|
||||||
import { ContactRaw } from '../models/contact.model';
|
PrivacySettingDto,
|
||||||
import { ChatRaw } from '../models/chat.model';
|
ReadMessageDto,
|
||||||
import { getMIMEType } from 'node-mime-types';
|
WhatsAppNumberDto,
|
||||||
|
} from '../dto/chat.dto';
|
||||||
|
import {
|
||||||
|
CreateGroupDto,
|
||||||
|
GetParticipant,
|
||||||
|
GroupDescriptionDto,
|
||||||
|
GroupInvite,
|
||||||
|
GroupJid,
|
||||||
|
GroupPictureDto,
|
||||||
|
GroupSendInvite,
|
||||||
|
GroupSubjectDto,
|
||||||
|
GroupToggleEphemeralDto,
|
||||||
|
GroupUpdateParticipantDto,
|
||||||
|
GroupUpdateSettingDto,
|
||||||
|
} from '../dto/group.dto';
|
||||||
import {
|
import {
|
||||||
ContactMessage,
|
ContactMessage,
|
||||||
MediaMessage,
|
MediaMessage,
|
||||||
@ -73,59 +106,26 @@ import {
|
|||||||
SendListDto,
|
SendListDto,
|
||||||
SendLocationDto,
|
SendLocationDto,
|
||||||
SendMediaDto,
|
SendMediaDto,
|
||||||
SendReactionDto,
|
|
||||||
SendTextDto,
|
|
||||||
SendPollDto,
|
SendPollDto,
|
||||||
SendStickerDto,
|
SendReactionDto,
|
||||||
SendStatusDto,
|
SendStatusDto,
|
||||||
|
SendStickerDto,
|
||||||
|
SendTextDto,
|
||||||
StatusMessage,
|
StatusMessage,
|
||||||
} from '../dto/sendMessage.dto';
|
} from '../dto/sendMessage.dto';
|
||||||
import { arrayUnique, isBase64, isURL } from 'class-validator';
|
|
||||||
import {
|
|
||||||
ArchiveChatDto,
|
|
||||||
DeleteMessage,
|
|
||||||
NumberBusiness,
|
|
||||||
OnWhatsAppDto,
|
|
||||||
PrivacySettingDto,
|
|
||||||
ReadMessageDto,
|
|
||||||
WhatsAppNumberDto,
|
|
||||||
getBase64FromMediaMessageDto,
|
|
||||||
} from '../dto/chat.dto';
|
|
||||||
import { MessageQuery } from '../repository/message.repository';
|
|
||||||
import { ContactQuery } from '../repository/contact.repository';
|
|
||||||
import {
|
|
||||||
BadRequestException,
|
|
||||||
InternalServerErrorException,
|
|
||||||
NotFoundException,
|
|
||||||
} from '../../exceptions';
|
|
||||||
import {
|
|
||||||
CreateGroupDto,
|
|
||||||
GroupInvite,
|
|
||||||
GroupJid,
|
|
||||||
GroupPictureDto,
|
|
||||||
GroupUpdateParticipantDto,
|
|
||||||
GroupUpdateSettingDto,
|
|
||||||
GroupToggleEphemeralDto,
|
|
||||||
GroupSubjectDto,
|
|
||||||
GroupDescriptionDto,
|
|
||||||
GroupSendInvite,
|
|
||||||
GetParticipant,
|
|
||||||
} from '../dto/group.dto';
|
|
||||||
import { MessageUpQuery } from '../repository/messageUp.repository';
|
|
||||||
import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-db';
|
|
||||||
import Long from 'long';
|
|
||||||
import { WebhookRaw } from '../models/webhook.model';
|
|
||||||
import { ChatwootRaw } from '../models/chatwoot.model';
|
|
||||||
import { dbserver } from '../../db/db.connect';
|
|
||||||
import NodeCache from 'node-cache';
|
|
||||||
import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-state-redis-db';
|
|
||||||
import sharp from 'sharp';
|
|
||||||
import { RedisCache } from '../../db/redis.client';
|
|
||||||
import { Log } from '../../config/env.config';
|
|
||||||
import ProxyAgent from 'proxy-agent';
|
|
||||||
import { ChatwootService } from './chatwoot.service';
|
|
||||||
import { waMonitor } from '../whatsapp.module';
|
|
||||||
import { SettingsRaw } from '../models';
|
import { SettingsRaw } from '../models';
|
||||||
|
import { ChatRaw } from '../models/chat.model';
|
||||||
|
import { ChatwootRaw } from '../models/chatwoot.model';
|
||||||
|
import { ContactRaw } from '../models/contact.model';
|
||||||
|
import { MessageRaw, MessageUpdateRaw } from '../models/message.model';
|
||||||
|
import { WebhookRaw } from '../models/webhook.model';
|
||||||
|
import { ContactQuery } from '../repository/contact.repository';
|
||||||
|
import { MessageQuery } from '../repository/message.repository';
|
||||||
|
import { MessageUpQuery } from '../repository/messageUp.repository';
|
||||||
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
|
import { Events, MessageSubtype, TypeMediaMessage, wa } from '../types/wa.types';
|
||||||
|
import { waMonitor } from '../whatsapp.module';
|
||||||
|
import { ChatwootService } from './chatwoot.service';
|
||||||
|
|
||||||
export class WAStartupService {
|
export class WAStartupService {
|
||||||
constructor(
|
constructor(
|
||||||
@ -395,7 +395,7 @@ export class WAStartupService {
|
|||||||
const webhookGlobal = this.configService.get<Webhook>('WEBHOOK');
|
const webhookGlobal = this.configService.get<Webhook>('WEBHOOK');
|
||||||
const webhookLocal = this.localWebhook.events;
|
const webhookLocal = this.localWebhook.events;
|
||||||
const serverUrl = this.configService.get<HttpServer>('SERVER').URL;
|
const serverUrl = this.configService.get<HttpServer>('SERVER').URL;
|
||||||
const we = event.replace(/[\.-]/gm, '_').toUpperCase();
|
const we = event.replace(/[.-]/gm, '_').toUpperCase();
|
||||||
const transformedWe = we.replace(/_/gm, '-').toLowerCase();
|
const transformedWe = we.replace(/_/gm, '-').toLowerCase();
|
||||||
|
|
||||||
const expose =
|
const expose =
|
||||||
@ -796,7 +796,9 @@ export class WAStartupService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
}, (cleanStore?.CLEANING_INTERVAL ?? 3600) * 1000);
|
}, (cleanStore?.CLEANING_INTERVAL ?? 3600) * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1514,7 +1516,7 @@ export class WAStartupService {
|
|||||||
.replace(/\+/g, '')
|
.replace(/\+/g, '')
|
||||||
.replace(/\(/g, '')
|
.replace(/\(/g, '')
|
||||||
.replace(/\)/g, '')
|
.replace(/\)/g, '')
|
||||||
.split(/\:/)[0]
|
.split(':')[0]
|
||||||
.split('@')[0];
|
.split('@')[0];
|
||||||
|
|
||||||
if (number.length >= 18) {
|
if (number.length >= 18) {
|
||||||
|
@ -1,43 +1,44 @@
|
|||||||
|
import { delay } from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
import { Auth, configService } from '../config/env.config';
|
import { Auth, configService } from '../config/env.config';
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
import { eventEmitter } from '../config/event.config';
|
import { eventEmitter } from '../config/event.config';
|
||||||
import { MessageRepository } from './repository/message.repository';
|
import { Logger } from '../config/logger.config';
|
||||||
import { WAMonitoringService } from './services/monitor.service';
|
import { dbserver } from '../db/db.connect';
|
||||||
import { ChatRepository } from './repository/chat.repository';
|
import { RedisCache } from '../db/redis.client';
|
||||||
import { ContactRepository } from './repository/contact.repository';
|
|
||||||
import { MessageUpRepository } from './repository/messageUp.repository';
|
|
||||||
import { ChatController } from './controllers/chat.controller';
|
import { ChatController } from './controllers/chat.controller';
|
||||||
|
import { ChatwootController } from './controllers/chatwoot.controller';
|
||||||
|
import { GroupController } from './controllers/group.controller';
|
||||||
import { InstanceController } from './controllers/instance.controller';
|
import { InstanceController } from './controllers/instance.controller';
|
||||||
import { SendMessageController } from './controllers/sendMessage.controller';
|
import { SendMessageController } from './controllers/sendMessage.controller';
|
||||||
import { AuthService } from './services/auth.service';
|
import { SettingsController } from './controllers/settings.controller';
|
||||||
import { GroupController } from './controllers/group.controller';
|
|
||||||
import { ViewsController } from './controllers/views.controller';
|
import { ViewsController } from './controllers/views.controller';
|
||||||
import { WebhookService } from './services/webhook.service';
|
|
||||||
import { WebhookController } from './controllers/webhook.controller';
|
import { WebhookController } from './controllers/webhook.controller';
|
||||||
import { ChatwootService } from './services/chatwoot.service';
|
|
||||||
import { ChatwootController } from './controllers/chatwoot.controller';
|
|
||||||
import { RepositoryBroker } from './repository/repository.manager';
|
|
||||||
import {
|
import {
|
||||||
AuthModel,
|
AuthModel,
|
||||||
ChatModel,
|
ChatModel,
|
||||||
|
ChatwootModel,
|
||||||
ContactModel,
|
ContactModel,
|
||||||
MessageModel,
|
MessageModel,
|
||||||
MessageUpModel,
|
MessageUpModel,
|
||||||
ChatwootModel,
|
|
||||||
WebhookModel,
|
|
||||||
SettingsModel,
|
SettingsModel,
|
||||||
|
WebhookModel,
|
||||||
} from './models';
|
} from './models';
|
||||||
import { dbserver } from '../db/db.connect';
|
|
||||||
import { WebhookRepository } from './repository/webhook.repository';
|
|
||||||
import { ChatwootRepository } from './repository/chatwoot.repository';
|
|
||||||
import { AuthRepository } from './repository/auth.repository';
|
import { AuthRepository } from './repository/auth.repository';
|
||||||
import { WAStartupService } from './services/whatsapp.service';
|
import { ChatRepository } from './repository/chat.repository';
|
||||||
import { delay } from '@whiskeysockets/baileys';
|
import { ChatwootRepository } from './repository/chatwoot.repository';
|
||||||
import { Events } from './types/wa.types';
|
import { ContactRepository } from './repository/contact.repository';
|
||||||
import { RedisCache } from '../db/redis.client';
|
import { MessageRepository } from './repository/message.repository';
|
||||||
|
import { MessageUpRepository } from './repository/messageUp.repository';
|
||||||
|
import { RepositoryBroker } from './repository/repository.manager';
|
||||||
import { SettingsRepository } from './repository/settings.repository';
|
import { SettingsRepository } from './repository/settings.repository';
|
||||||
|
import { WebhookRepository } from './repository/webhook.repository';
|
||||||
|
import { AuthService } from './services/auth.service';
|
||||||
|
import { ChatwootService } from './services/chatwoot.service';
|
||||||
|
import { WAMonitoringService } from './services/monitor.service';
|
||||||
import { SettingsService } from './services/settings.service';
|
import { SettingsService } from './services/settings.service';
|
||||||
import { SettingsController } from './controllers/settings.controller';
|
import { WebhookService } from './services/webhook.service';
|
||||||
|
import { WAStartupService } from './services/whatsapp.service';
|
||||||
|
import { Events } from './types/wa.types';
|
||||||
|
|
||||||
const logger = new Logger('WA MODULE');
|
const logger = new Logger('WA MODULE');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user