mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
Update ESLint configuration, Dockerfile, and package dependencies; refactor bot trigger logic
- Updated ESLint configuration to use TypeScript project references and adjusted parser options. - Modified Dockerfile to include OpenSSL in both builder and final stages. - Changed `mime` package version from `^4.0.6` to `^3.0.0` in `package.json` and updated TypeScript ESLint packages to `^6.21.0`. - Refactored `findBotByTrigger` function to remove unnecessary settings repository parameter. - Adjusted bot trigger logic in multiple controller files to streamline function calls.
This commit is contained in:
parent
ca451bfacc
commit
d598c4ed0b
@ -1,7 +1,11 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
sourceType: 'CommonJS',
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
sourceType: 'commonjs',
|
||||||
|
warnOnUnsupportedTypeScriptVersion: false,
|
||||||
|
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
||||||
},
|
},
|
||||||
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
|
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
|
||||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
|
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add git ffmpeg wget curl bash
|
apk add git ffmpeg wget curl bash openssl
|
||||||
|
|
||||||
LABEL version="2.2.0" description="Api to control whatsapp features through http requests."
|
LABEL version="2.2.0" description="Api to control whatsapp features through http requests."
|
||||||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
||||||
@ -32,7 +32,7 @@ RUN npm run build
|
|||||||
FROM node:20-alpine AS final
|
FROM node:20-alpine AS final
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add tzdata ffmpeg bash
|
apk add tzdata ffmpeg bash openssl
|
||||||
|
|
||||||
ENV TZ=America/Sao_Paulo
|
ENV TZ=America/Sao_Paulo
|
||||||
|
|
||||||
|
3655
package-lock.json
generated
3655
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@
|
|||||||
"link-preview-js": "^3.0.13",
|
"link-preview-js": "^3.0.13",
|
||||||
"long": "^5.2.3",
|
"long": "^5.2.3",
|
||||||
"mediainfo.js": "^0.3.4",
|
"mediainfo.js": "^0.3.4",
|
||||||
"mime": "^4.0.6",
|
"mime": "^3.0.0",
|
||||||
"minio": "^8.0.3",
|
"minio": "^8.0.3",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
@ -99,14 +99,13 @@
|
|||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/express": "^4.17.18",
|
"@types/express": "^4.17.18",
|
||||||
"@types/json-schema": "^7.0.15",
|
"@types/json-schema": "^7.0.15",
|
||||||
"@types/mime": "4.0.0",
|
|
||||||
"@types/node": "^22.10.5",
|
"@types/node": "^22.10.5",
|
||||||
"@types/node-cron": "^3.0.11",
|
"@types/node-cron": "^3.0.11",
|
||||||
"@types/qrcode": "^1.5.5",
|
"@types/qrcode": "^1.5.5",
|
||||||
"@types/qrcode-terminal": "^0.12.2",
|
"@types/qrcode-terminal": "^0.12.2",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^6.21.0",
|
||||||
"eslint": "^8.45.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
|
@ -271,7 +271,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
public async getProfileStatus() {
|
public async getProfileStatus() {
|
||||||
const status = await this.client.fetchStatus(this.instance.wuid);
|
const status = await this.client.fetchStatus(this.instance.wuid);
|
||||||
|
|
||||||
return status?.status;
|
return status[0]?.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get profilePictureUrl() {
|
public get profilePictureUrl() {
|
||||||
@ -974,7 +974,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
const messagesRaw: any[] = [];
|
const messagesRaw: any[] = [];
|
||||||
|
|
||||||
const messagesRepository = new Set(
|
const messagesRepository: Set<string> = new Set(
|
||||||
chatwootImport.getRepositoryMessagesCache(instance) ??
|
chatwootImport.getRepositoryMessagesCache(instance) ??
|
||||||
(
|
(
|
||||||
await this.prismaRepository.message.findMany({
|
await this.prismaRepository.message.findMany({
|
||||||
@ -1790,7 +1790,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
wuid: jid,
|
wuid: jid,
|
||||||
status: (await this.client.fetchStatus(jid))?.status,
|
status: (await this.client.fetchStatus(jid))[0]?.status,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
|
@ -184,7 +184,6 @@ export class ChatbotController {
|
|||||||
|
|
||||||
public async findBotTrigger(
|
public async findBotTrigger(
|
||||||
botRepository: any,
|
botRepository: any,
|
||||||
settingsRepository: any,
|
|
||||||
content: string,
|
content: string,
|
||||||
instance: InstanceDto,
|
instance: InstanceDto,
|
||||||
session?: IntegrationSession,
|
session?: IntegrationSession,
|
||||||
@ -192,7 +191,7 @@ export class ChatbotController {
|
|||||||
let findBot: null;
|
let findBot: null;
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
findBot = await findBotByTrigger(botRepository, settingsRepository, content, instance.instanceId);
|
findBot = await findBotByTrigger(botRepository, content, instance.instanceId);
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
return;
|
return;
|
||||||
|
@ -756,13 +756,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
let findBot = (await this.findBotTrigger(
|
let findBot = (await this.findBotTrigger(this.botRepository, content, instance, session)) as DifyModel;
|
||||||
this.botRepository,
|
|
||||||
this.settingsRepository,
|
|
||||||
content,
|
|
||||||
instance,
|
|
||||||
session,
|
|
||||||
)) as DifyModel;
|
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
const fallback = await this.settingsRepository.findFirst({
|
const fallback = await this.settingsRepository.findFirst({
|
||||||
|
@ -728,13 +728,7 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
let findBot = (await this.findBotTrigger(
|
let findBot = (await this.findBotTrigger(this.botRepository, content, instance, session)) as EvolutionBot;
|
||||||
this.botRepository,
|
|
||||||
this.settingsRepository,
|
|
||||||
content,
|
|
||||||
instance,
|
|
||||||
session,
|
|
||||||
)) as EvolutionBot;
|
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
const fallback = await this.settingsRepository.findFirst({
|
const fallback = await this.settingsRepository.findFirst({
|
||||||
|
@ -728,13 +728,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
let findBot = (await this.findBotTrigger(
|
let findBot = (await this.findBotTrigger(this.botRepository, content, instance, session)) as Flowise;
|
||||||
this.botRepository,
|
|
||||||
this.settingsRepository,
|
|
||||||
content,
|
|
||||||
instance,
|
|
||||||
session,
|
|
||||||
)) as Flowise;
|
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
const fallback = await this.settingsRepository.findFirst({
|
const fallback = await this.settingsRepository.findFirst({
|
||||||
|
@ -965,13 +965,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
let findBot = (await this.findBotTrigger(
|
let findBot = (await this.findBotTrigger(this.botRepository, content, instance, session)) as OpenaiBot;
|
||||||
this.botRepository,
|
|
||||||
this.settingsRepository,
|
|
||||||
content,
|
|
||||||
instance,
|
|
||||||
session,
|
|
||||||
)) as OpenaiBot;
|
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
const fallback = await this.settingsRepository.findFirst({
|
const fallback = await this.settingsRepository.findFirst({
|
||||||
|
@ -943,13 +943,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
|||||||
|
|
||||||
const content = getConversationMessage(msg);
|
const content = getConversationMessage(msg);
|
||||||
|
|
||||||
let findBot = (await this.findBotTrigger(
|
let findBot = (await this.findBotTrigger(this.botRepository, content, instance, session)) as TypebotModel;
|
||||||
this.botRepository,
|
|
||||||
this.settingsRepository,
|
|
||||||
content,
|
|
||||||
instance,
|
|
||||||
session,
|
|
||||||
)) as TypebotModel;
|
|
||||||
|
|
||||||
if (!findBot) {
|
if (!findBot) {
|
||||||
const fallback = await this.settingsRepository.findFirst({
|
const fallback = await this.settingsRepository.findFirst({
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import { advancedOperatorsSearch } from './advancedOperatorsSearch';
|
import { advancedOperatorsSearch } from './advancedOperatorsSearch';
|
||||||
|
|
||||||
export const findBotByTrigger = async (
|
export const findBotByTrigger = async (botRepository: any, content: string, instanceId: string) => {
|
||||||
botRepository: any,
|
|
||||||
settingsRepository: any,
|
|
||||||
content: string,
|
|
||||||
instanceId: string,
|
|
||||||
) => {
|
|
||||||
// Check for triggerType 'all'
|
// Check for triggerType 'all'
|
||||||
const findTriggerAll = await botRepository.findFirst({
|
const findTriggerAll = await botRepository.findFirst({
|
||||||
where: {
|
where: {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"target": "es2020",
|
"target": "es2020",
|
||||||
"module": "commonjs",
|
"module": "NodeNext",
|
||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
@ -26,7 +26,8 @@
|
|||||||
"@libs/*": ["./src/libs/*"],
|
"@libs/*": ["./src/libs/*"],
|
||||||
"@utils/*": ["./src/utils/*"],
|
"@utils/*": ["./src/utils/*"],
|
||||||
"@validate/*": ["./src/validate/*"]
|
"@validate/*": ["./src/validate/*"]
|
||||||
}
|
},
|
||||||
|
"moduleResolution": "NodeNext"
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "./test", "./dist", "./prisma"],
|
"exclude": ["node_modules", "./test", "./dist", "./prisma"],
|
||||||
"include": [
|
"include": [
|
||||||
|
Loading…
Reference in New Issue
Block a user