Skip to content

Commit fcc2c5f

Browse files
committed
refactor: clear integrations and dependencies
1 parent 3c3458b commit fcc2c5f

File tree

61 files changed

+76
-14237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+76
-14237
lines changed

.env.example

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DATABASE_PROVIDER=postgresql
2929
DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'
3030
# Client name for the database connection
3131
# It is used to separate an API installation from another that uses the same database.
32-
DATABASE_CONNECTION_CLIENT_NAME=evolution_exchange
32+
DATABASE_CONNECTION_CLIENT_NAME=evolution
3333

3434
# Choose the data you want to save in the application's database
3535
DATABASE_SAVE_DATA_INSTANCE=true
@@ -148,30 +148,6 @@ CONFIG_SESSION_PHONE_VERSION=2.3000.1015901307
148148
QRCODE_LIMIT=30
149149
# Color of the QRCode on base64
150150
QRCODE_COLOR='#175197'
151-
152-
# Typebot - Environment variables
153-
TYPEBOT_ENABLED=false
154-
# old | latest
155-
TYPEBOT_API_VERSION=latest
156-
157-
# Chatwoot - Environment variables
158-
CHATWOOT_ENABLED=false
159-
# If you leave this option as false, when deleting the message for everyone on WhatsApp, it will not be deleted on Chatwoot.
160-
CHATWOOT_MESSAGE_READ=true
161-
# If you leave this option as true, when sending a message in Chatwoot, the client's last message will be marked as read on WhatsApp.
162-
CHATWOOT_MESSAGE_DELETE=true
163-
# If you leave this option as true, a contact will be created on Chatwoot to provide the QR Code and update messages about the instance.
164-
CHATWOOT_BOT_CONTACT=true
165-
# This db connection is used to import messages from whatsapp to chatwoot database
166-
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgresql://user:passwprd@host:5432/chatwoot?sslmode=disable
167-
CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE=true
168-
169-
# OpenAI - Environment variables
170-
OPENAI_ENABLED=false
171-
172-
# Dify - Environment variables
173-
DIFY_ENABLED=false
174-
175151
# Cache - Environment variables
176152
# Redis Cache enabled
177153
CACHE_REDIS_ENABLED=true

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
FROM node:20-alpine AS builder
22

33
RUN apk update && \
4-
apk add git ffmpeg wget curl bash
4+
apk add git wget curl bash
55

6-
LABEL version="2.1.2" description="Api to control whatsapp features through http requests."
7-
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
8-
LABEL contact="contato@atendai.com"
6+
LABEL version="2.1.2-lite" description="Api to control whatsapp features through http requests."
7+
LABEL maintainer="Davidson Gomes" git="https://github.com/EvolutionAPI"
8+
LABEL contact="davidson@evolution-api.com"
99

1010
WORKDIR /evolution
1111

1212
COPY ./package.json ./tsconfig.json ./
1313

14-
RUN npm install -f
14+
RUN npm install --omit=dev
1515

1616
COPY ./src ./src
1717
COPY ./public ./public
@@ -32,7 +32,7 @@ RUN npm run build
3232
FROM node:20-alpine AS final
3333

3434
RUN apk update && \
35-
apk add tzdata ffmpeg bash
35+
apk add tzdata bash
3636

3737
ENV TZ=America/Sao_Paulo
3838

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ b. Your contributed code may be used for commercial purposes, including but not
2020

2121
Apart from the specific conditions mentioned above, all other rights and restrictions follow the Apache License 2.0. Detailed information about the Apache License 2.0 can be found at http://www.apache.org/licenses/LICENSE-2.0.
2222

23-
© 2024 AtendAI
23+
© 2024 Evolution API
2424

package.json

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "evolution-api",
3-
"version": "2.1.2",
2+
"name": "evolution-api-lite",
3+
"version": "2.1.2-lite",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/main.js",
66
"type": "commonjs",
@@ -18,7 +18,7 @@
1818
},
1919
"repository": {
2020
"type": "git",
21-
"url": "git+https://github.com/EvolutionAPI/evolution-api.git"
21+
"url": "git+https://github.com/EvolutionAPI/evolution-api-lite.git"
2222
},
2323
"keywords": [
2424
"chat",
@@ -48,8 +48,6 @@
4848
"dependencies": {
4949
"@adiwajshing/keyed-db": "^0.2.4",
5050
"@aws-sdk/client-sqs": "^3.569.0",
51-
"@ffmpeg-installer/ffmpeg": "^1.1.0",
52-
"@figuro/chatwoot-sdk": "^1.1.16",
5351
"@hapi/boom": "^10.0.1",
5452
"@prisma/client": "^5.15.0",
5553
"@sentry/node": "^8.28.0",
@@ -59,56 +57,38 @@
5957
"class-validator": "^0.14.1",
6058
"compression": "^1.7.4",
6159
"cors": "^2.8.5",
62-
"cross-env": "^7.0.3",
6360
"dayjs": "^1.11.7",
6461
"dotenv": "^16.4.5",
6562
"eventemitter2": "^6.4.9",
66-
"exiftool-vendored": "^22.0.0",
6763
"express": "^4.18.2",
6864
"express-async-errors": "^3.1.1",
69-
"fluent-ffmpeg": "^2.1.2",
7065
"form-data": "^4.0.0",
71-
"hbs": "^4.2.0",
7266
"https-proxy-agent": "^7.0.2",
7367
"i18next": "^23.7.19",
7468
"jimp": "^0.16.13",
75-
"join": "^3.0.0",
76-
"js-yaml": "^4.1.0",
7769
"json-schema": "^0.4.0",
7870
"jsonschema": "^1.4.1",
7971
"link-preview-js": "^3.0.4",
8072
"long": "^5.2.3",
8173
"mime": "^3.0.0",
82-
"minio": "^8.0.1",
8374
"node-cache": "^5.1.2",
84-
"node-cron": "^3.0.3",
85-
"node-windows": "^1.0.0-beta.8",
86-
"openai": "^4.52.7",
87-
"parse-bmfont-xml": "^1.1.4",
88-
"pg": "^8.11.3",
8975
"pino": "^8.11.0",
9076
"prisma": "^5.15.0",
9177
"qrcode": "^1.5.1",
9278
"qrcode-terminal": "^0.12.0",
9379
"redis": "^4.6.5",
9480
"sharp": "^0.32.2",
9581
"socket.io": "^4.7.1",
96-
"socks-proxy-agent": "^8.0.1",
9782
"tsup": "^8.2.4",
98-
"uuid": "^9.0.0",
99-
"xml2js": "^0.6.2",
100-
"yamljs": "^0.3.0"
83+
"uuid": "^9.0.0"
10184
},
10285
"devDependencies": {
10386
"@types/compression": "^1.7.2",
10487
"@types/cors": "^2.8.13",
10588
"@types/express": "^4.17.17",
106-
"@types/js-yaml": "^4.0.5",
10789
"@types/json-schema": "^7.0.15",
10890
"@types/mime": "3.0.0",
10991
"@types/node": "^18.15.11",
110-
"@types/node-cron": "^3.0.11",
111-
"@types/node-windows": "^0.1.2",
11292
"@types/qrcode": "^1.5.0",
11393
"@types/qrcode-terminal": "^0.12.0",
11494
"@types/uuid": "^8.3.4",

src/api/controllers/instance.controller.ts

Lines changed: 11 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { InstanceDto, SetPresenceDto } from '@api/dto/instance.dto';
2-
import { ChatwootService } from '@api/integrations/chatbot/chatwoot/services/chatwoot.service';
32
import { ProviderFiles } from '@api/provider/sessions';
43
import { PrismaRepository } from '@api/repository/repository.service';
54
import { channelController, eventManager } from '@api/server.module';
65
import { CacheService } from '@api/services/cache.service';
76
import { WAMonitoringService } from '@api/services/monitor.service';
87
import { SettingsService } from '@api/services/settings.service';
98
import { Events, Integration, wa } from '@api/types/wa.types';
10-
import { Auth, Chatwoot, ConfigService, HttpServer, WaBusiness } from '@config/env.config';
9+
import { Auth, ConfigService, HttpServer, WaBusiness } from '@config/env.config';
1110
import { Logger } from '@config/logger.config';
1211
import { BadRequestException, InternalServerErrorException, UnauthorizedException } from '@exceptions';
1312
import { delay } from 'baileys';
14-
import { isArray, isURL } from 'class-validator';
13+
import { isArray } from 'class-validator';
1514
import EventEmitter2 from 'eventemitter2';
1615
import { v4 } from 'uuid';
1716

@@ -23,11 +22,9 @@ export class InstanceController {
2322
private readonly configService: ConfigService,
2423
private readonly prismaRepository: PrismaRepository,
2524
private readonly eventEmitter: EventEmitter2,
26-
private readonly chatwootService: ChatwootService,
2725
private readonly settingsService: SettingsService,
2826
private readonly proxyService: ProxyController,
2927
private readonly cache: CacheService,
30-
private readonly chatwootCache: CacheService,
3128
private readonly baileysCache: CacheService,
3229
private readonly providerFiles: ProviderFiles,
3330
) {}
@@ -41,7 +38,6 @@ export class InstanceController {
4138
eventEmitter: this.eventEmitter,
4239
prismaRepository: this.prismaRepository,
4340
cache: this.cache,
44-
chatwootCache: this.chatwootCache,
4541
baileysCache: this.baileysCache,
4642
providerFiles: this.providerFiles,
4743
});
@@ -135,104 +131,15 @@ export class InstanceController {
135131
accessTokenWaBusiness = this.configService.get<WaBusiness>('WA_BUSINESS').TOKEN_WEBHOOK;
136132
}
137133

138-
if (!instanceData.chatwootAccountId || !instanceData.chatwootToken || !instanceData.chatwootUrl) {
139-
let getQrcode: wa.QrCode;
134+
let getQrcode: wa.QrCode;
140135

141-
if (instanceData.qrcode && instanceData.integration === Integration.WHATSAPP_BAILEYS) {
142-
await instance.connectToWhatsapp(instanceData.number);
143-
await delay(5000);
144-
getQrcode = instance.qrCode;
145-
}
146-
147-
const result = {
148-
instance: {
149-
instanceName: instance.instanceName,
150-
instanceId: instanceId,
151-
integration: instanceData.integration,
152-
webhookWaBusiness,
153-
accessTokenWaBusiness,
154-
status: instance.connectionStatus.state,
155-
},
156-
hash,
157-
webhook: {
158-
webhookUrl: instanceData?.webhook?.url,
159-
webhookHeaders: instanceData?.webhook?.headers,
160-
webhookByEvents: instanceData?.webhook?.byEvents,
161-
webhookBase64: instanceData?.webhook?.base64,
162-
},
163-
websocket: {
164-
enabled: instanceData?.websocket?.enabled,
165-
},
166-
rabbitmq: {
167-
enabled: instanceData?.rabbitmq?.enabled,
168-
},
169-
sqs: {
170-
enabled: instanceData?.sqs?.enabled,
171-
},
172-
settings,
173-
qrcode: getQrcode,
174-
};
175-
176-
return result;
177-
}
178-
179-
if (!this.configService.get<Chatwoot>('CHATWOOT').ENABLED)
180-
throw new BadRequestException('Chatwoot is not enabled');
181-
182-
if (!instanceData.chatwootAccountId) {
183-
throw new BadRequestException('accountId is required');
184-
}
185-
186-
if (!instanceData.chatwootToken) {
187-
throw new BadRequestException('token is required');
188-
}
189-
190-
if (!instanceData.chatwootUrl) {
191-
throw new BadRequestException('url is required');
192-
}
193-
194-
if (!isURL(instanceData.chatwootUrl, { require_tld: false })) {
195-
throw new BadRequestException('Invalid "url" property in chatwoot');
196-
}
197-
198-
if (instanceData.chatwootSignMsg !== true && instanceData.chatwootSignMsg !== false) {
199-
throw new BadRequestException('signMsg is required');
200-
}
201-
202-
if (instanceData.chatwootReopenConversation !== true && instanceData.chatwootReopenConversation !== false) {
203-
throw new BadRequestException('reopenConversation is required');
136+
if (instanceData.qrcode && instanceData.integration === Integration.WHATSAPP_BAILEYS) {
137+
await instance.connectToWhatsapp(instanceData.number);
138+
await delay(5000);
139+
getQrcode = instance.qrCode;
204140
}
205141

206-
if (instanceData.chatwootConversationPending !== true && instanceData.chatwootConversationPending !== false) {
207-
throw new BadRequestException('conversationPending is required');
208-
}
209-
210-
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
211-
212-
try {
213-
this.chatwootService.create(instance, {
214-
enabled: true,
215-
accountId: instanceData.chatwootAccountId,
216-
token: instanceData.chatwootToken,
217-
url: instanceData.chatwootUrl,
218-
signMsg: instanceData.chatwootSignMsg || false,
219-
nameInbox: instanceData.chatwootNameInbox ?? instance.instanceName.split('-cwId-')[0],
220-
number: instanceData.number,
221-
reopenConversation: instanceData.chatwootReopenConversation || false,
222-
conversationPending: instanceData.chatwootConversationPending || false,
223-
importContacts: instanceData.chatwootImportContacts ?? true,
224-
mergeBrazilContacts: instanceData.chatwootMergeBrazilContacts ?? false,
225-
importMessages: instanceData.chatwootImportMessages ?? true,
226-
daysLimitImportMessages: instanceData.chatwootDaysLimitImportMessages ?? 60,
227-
organization: instanceData.chatwootOrganization,
228-
logo: instanceData.chatwootLogo,
229-
autoCreate: instanceData.chatwootAutoCreate !== false,
230-
});
231-
} catch (error) {
232-
this.logger.log(error);
233-
}
234-
235-
return {
142+
const result = {
236143
instance: {
237144
instanceName: instance.instanceName,
238145
instanceId: instanceId,
@@ -258,23 +165,10 @@ export class InstanceController {
258165
enabled: instanceData?.sqs?.enabled,
259166
},
260167
settings,
261-
chatwoot: {
262-
enabled: true,
263-
accountId: instanceData.chatwootAccountId,
264-
token: instanceData.chatwootToken,
265-
url: instanceData.chatwootUrl,
266-
signMsg: instanceData.chatwootSignMsg || false,
267-
reopenConversation: instanceData.chatwootReopenConversation || false,
268-
conversationPending: instanceData.chatwootConversationPending || false,
269-
mergeBrazilContacts: instanceData.chatwootMergeBrazilContacts ?? false,
270-
importContacts: instanceData.chatwootImportContacts ?? true,
271-
importMessages: instanceData.chatwootImportMessages ?? true,
272-
daysLimitImportMessages: instanceData.chatwootDaysLimitImportMessages || 60,
273-
number: instanceData.number,
274-
nameInbox: instanceData.chatwootNameInbox ?? instance.instanceName,
275-
webhookUrl: `${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
276-
},
168+
qrcode: getQrcode,
277169
};
170+
171+
return result;
278172
} catch (error) {
279173
this.waMonitor.deleteInstance(instanceData.instanceName);
280174
this.logger.error(isArray(error.message) ? error.message[0] : error.message);
@@ -331,7 +225,6 @@ export class InstanceController {
331225
if (state == 'close') {
332226
throw new BadRequestException('The "' + instanceName + '" instance is not connected');
333227
} else if (state == 'open') {
334-
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) instance.clearCacheChatwoot();
335228
this.logger.info('restarting instance' + instanceName);
336229

337230
instance.client?.ws?.close();
@@ -415,8 +308,6 @@ export class InstanceController {
415308
}
416309
try {
417310
const waInstances = this.waMonitor.waInstances[instanceName];
418-
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) waInstances?.clearCacheChatwoot();
419-
420311
if (instance.state === 'connecting') {
421312
await this.logout({ instanceName });
422313
}

0 commit comments

Comments
 (0)