mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
git actions v2
This commit is contained in:
parent
71a97e047a
commit
14e7a68c32
16
.env.example
16
.env.example
@ -18,21 +18,9 @@ PROVIDER_HOST=127.0.0.1
|
|||||||
PROVIDER_PORT=5656
|
PROVIDER_PORT=5656
|
||||||
PROVIDER_PREFIX=evolution
|
PROVIDER_PREFIX=evolution
|
||||||
|
|
||||||
STORE_MESSAGES=true
|
DATABASE_ENABLED=true
|
||||||
STORE_MESSAGE_UP=true
|
|
||||||
STORE_CONTACTS=true
|
|
||||||
STORE_CHATS=true
|
|
||||||
|
|
||||||
CLEAN_STORE_CLEANING_INTERVAL=7200
|
|
||||||
CLEAN_STORE_MESSAGES=true
|
|
||||||
CLEAN_STORE_MESSAGE_UP=true
|
|
||||||
CLEAN_STORE_CONTACTS=true
|
|
||||||
CLEAN_STORE_CHATS=true
|
|
||||||
|
|
||||||
DATABASE_ENABLED=false
|
|
||||||
DATABASE_PROVIDER=postgresql # postgresql, mysql
|
DATABASE_PROVIDER=postgresql # postgresql, mysql
|
||||||
DATABASE_PROVIDER=mongodb # postgresql, mysql
|
DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'
|
||||||
DATABASE_CONNECTION_URI='mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true'
|
|
||||||
DATABASE_CONNECTION_CLIENT_NAME=evolution
|
DATABASE_CONNECTION_CLIENT_NAME=evolution
|
||||||
DATABASE_SAVE_DATA_INSTANCE=true
|
DATABASE_SAVE_DATA_INSTANCE=true
|
||||||
DATABASE_SAVE_DATA_NEW_MESSAGE=true
|
DATABASE_SAVE_DATA_NEW_MESSAGE=true
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -19,13 +19,19 @@ COPY ./package.json ./tsconfig.json ./
|
|||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY ./src ./src
|
||||||
|
COPY ./public ./public
|
||||||
|
COPY ./prisma ./prisma
|
||||||
|
COPY ./views ./views
|
||||||
|
COPY ./.env.dev ./.env
|
||||||
|
|
||||||
RUN chmod +x ./deploy_database.sh
|
COPY ./Docker ./Docker
|
||||||
|
|
||||||
|
RUN chmod +x ./Docker/deploy_database.sh
|
||||||
|
|
||||||
ENV DATABASE_CONNECTION_URI=postgres://postgres:pass@localhost/evolution
|
ENV DATABASE_CONNECTION_URI=postgres://postgres:pass@localhost/evolution
|
||||||
|
|
||||||
RUN ./deploy_database.sh
|
RUN ./Docker/deploy_database.sh
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Contact, Message } from '@prisma/client';
|
import { Contact, Message } from '@prisma/client';
|
||||||
import { WASocket } from '@whiskeysockets/baileys';
|
import { WASocket } from '@whiskeysockets/baileys';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { execSync } from 'child_process';
|
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@ -10,9 +9,7 @@ import { v4 } from 'uuid';
|
|||||||
import {
|
import {
|
||||||
Auth,
|
Auth,
|
||||||
Chatwoot,
|
Chatwoot,
|
||||||
CleanStoreConf,
|
|
||||||
ConfigService,
|
ConfigService,
|
||||||
Database,
|
|
||||||
HttpServer,
|
HttpServer,
|
||||||
Log,
|
Log,
|
||||||
Rabbitmq,
|
Rabbitmq,
|
||||||
@ -986,26 +983,6 @@ export class ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public cleanStore() {
|
|
||||||
const cleanStore = this.configService.get<CleanStoreConf>('CLEAN_STORE');
|
|
||||||
const database = this.configService.get<Database>('DATABASE');
|
|
||||||
if (cleanStore?.CLEANING_INTERVAL && !database.ENABLED) {
|
|
||||||
setInterval(() => {
|
|
||||||
try {
|
|
||||||
for (const [key, value] of Object.entries(cleanStore)) {
|
|
||||||
if (value === true) {
|
|
||||||
execSync(
|
|
||||||
`rm -rf ${join(this.storePath, key.toLowerCase().replace('_', '-'), this.instance.name)}/*.json`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
}
|
|
||||||
}, (cleanStore?.CLEANING_INTERVAL ?? 3600) * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the number is MX or AR
|
// Check if the number is MX or AR
|
||||||
public formatMXOrARNumber(jid: string): string {
|
public formatMXOrARNumber(jid: string): string {
|
||||||
const countryCode = jid.substring(0, 2);
|
const countryCode = jid.substring(0, 2);
|
||||||
|
@ -139,7 +139,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
private readonly providerFiles: ProviderFiles,
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {
|
) {
|
||||||
super(configService, eventEmitter, prismaRepository, chatwootCache);
|
super(configService, eventEmitter, prismaRepository, chatwootCache);
|
||||||
this.cleanStore();
|
|
||||||
this.instance.qrcode = { count: 0 };
|
this.instance.qrcode = { count: 0 };
|
||||||
this.recoveringMessages();
|
this.recoveringMessages();
|
||||||
this.cronForceUpdateGroupMetadataCache();
|
this.cronForceUpdateGroupMetadataCache();
|
||||||
|
@ -39,7 +39,6 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
private readonly providerFiles: ProviderFiles,
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {
|
) {
|
||||||
super(configService, eventEmitter, prismaRepository, chatwootCache);
|
super(configService, eventEmitter, prismaRepository, chatwootCache);
|
||||||
this.cleanStore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public stateConnection: wa.StateConnection = { state: 'open' };
|
public stateConnection: wa.StateConnection = { state: 'open' };
|
||||||
|
@ -44,22 +44,6 @@ export type SaveData = {
|
|||||||
LABELS: boolean;
|
LABELS: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StoreConf = {
|
|
||||||
MESSAGES: boolean;
|
|
||||||
MESSAGE_UP: boolean;
|
|
||||||
CONTACTS: boolean;
|
|
||||||
CHATS: boolean;
|
|
||||||
LABELS: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CleanStoreConf = {
|
|
||||||
CLEANING_INTERVAL: number;
|
|
||||||
MESSAGES: boolean;
|
|
||||||
MESSAGE_UP: boolean;
|
|
||||||
CONTACTS: boolean;
|
|
||||||
CHATS: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DBConnection = {
|
export type DBConnection = {
|
||||||
URI: string;
|
URI: string;
|
||||||
CLIENT_NAME: string;
|
CLIENT_NAME: string;
|
||||||
@ -215,8 +199,6 @@ export interface Env {
|
|||||||
CORS: Cors;
|
CORS: Cors;
|
||||||
SSL_CONF: SslConf;
|
SSL_CONF: SslConf;
|
||||||
PROVIDER: ProviderSession;
|
PROVIDER: ProviderSession;
|
||||||
STORE: StoreConf;
|
|
||||||
CLEAN_STORE: CleanStoreConf;
|
|
||||||
DATABASE: Database;
|
DATABASE: Database;
|
||||||
RABBITMQ: Rabbitmq;
|
RABBITMQ: Rabbitmq;
|
||||||
SQS: Sqs;
|
SQS: Sqs;
|
||||||
@ -282,22 +264,6 @@ export class ConfigService {
|
|||||||
PORT: process.env?.PROVIDER_PORT || '5656',
|
PORT: process.env?.PROVIDER_PORT || '5656',
|
||||||
PREFIX: process.env?.PROVIDER_PREFIX || 'evolution',
|
PREFIX: process.env?.PROVIDER_PREFIX || 'evolution',
|
||||||
},
|
},
|
||||||
STORE: {
|
|
||||||
MESSAGES: process.env?.STORE_MESSAGES === 'true',
|
|
||||||
MESSAGE_UP: process.env?.STORE_MESSAGE_UP === 'true',
|
|
||||||
CONTACTS: process.env?.STORE_CONTACTS === 'true',
|
|
||||||
CHATS: process.env?.STORE_CHATS === 'true',
|
|
||||||
LABELS: process.env?.STORE_LABELS === 'true',
|
|
||||||
},
|
|
||||||
CLEAN_STORE: {
|
|
||||||
CLEANING_INTERVAL: Number.isInteger(process.env?.CLEAN_STORE_CLEANING_INTERVAL)
|
|
||||||
? Number.parseInt(process.env.CLEAN_STORE_CLEANING_INTERVAL)
|
|
||||||
: 7200,
|
|
||||||
MESSAGES: process.env?.CLEAN_STORE_MESSAGES === 'true',
|
|
||||||
MESSAGE_UP: process.env?.CLEAN_STORE_MESSAGE_UP === 'true',
|
|
||||||
CONTACTS: process.env?.CLEAN_STORE_CONTACTS === 'true',
|
|
||||||
CHATS: process.env?.CLEAN_STORE_CHATS === 'true',
|
|
||||||
},
|
|
||||||
DATABASE: {
|
DATABASE: {
|
||||||
CONNECTION: {
|
CONNECTION: {
|
||||||
URI: process.env.DATABASE_CONNECTION_URI || '',
|
URI: process.env.DATABASE_CONNECTION_URI || '',
|
||||||
|
Loading…
Reference in New Issue
Block a user