git actions v2

This commit is contained in:
Davidson Gomes 2024-06-09 14:49:09 -03:00
parent 71a97e047a
commit 14e7a68c32
7 changed files with 11 additions and 76 deletions

View File

@ -18,21 +18,9 @@ PROVIDER_HOST=127.0.0.1
PROVIDER_PORT=5656
PROVIDER_PREFIX=evolution
STORE_MESSAGES=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_ENABLED=true
DATABASE_PROVIDER=postgresql # postgresql, mysql
DATABASE_PROVIDER=mongodb # postgresql, mysql
DATABASE_CONNECTION_URI='mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true'
DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'
DATABASE_CONNECTION_CLIENT_NAME=evolution
DATABASE_SAVE_DATA_INSTANCE=true
DATABASE_SAVE_DATA_NEW_MESSAGE=true

View File

@ -19,13 +19,19 @@ COPY ./package.json ./tsconfig.json ./
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
RUN ./deploy_database.sh
RUN ./Docker/deploy_database.sh
RUN npm run build

View File

@ -1,7 +1,6 @@
import { Contact, Message } from '@prisma/client';
import { WASocket } from '@whiskeysockets/baileys';
import axios from 'axios';
import { execSync } from 'child_process';
import { isURL } from 'class-validator';
import EventEmitter2 from 'eventemitter2';
import { join } from 'path';
@ -10,9 +9,7 @@ import { v4 } from 'uuid';
import {
Auth,
Chatwoot,
CleanStoreConf,
ConfigService,
Database,
HttpServer,
Log,
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
public formatMXOrARNumber(jid: string): string {
const countryCode = jid.substring(0, 2);

View File

@ -139,7 +139,6 @@ export class BaileysStartupService extends ChannelStartupService {
private readonly providerFiles: ProviderFiles,
) {
super(configService, eventEmitter, prismaRepository, chatwootCache);
this.cleanStore();
this.instance.qrcode = { count: 0 };
this.recoveringMessages();
this.cronForceUpdateGroupMetadataCache();

View File

@ -39,7 +39,6 @@ export class BusinessStartupService extends ChannelStartupService {
private readonly providerFiles: ProviderFiles,
) {
super(configService, eventEmitter, prismaRepository, chatwootCache);
this.cleanStore();
}
public stateConnection: wa.StateConnection = { state: 'open' };

View File

@ -44,22 +44,6 @@ export type SaveData = {
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 = {
URI: string;
CLIENT_NAME: string;
@ -215,8 +199,6 @@ export interface Env {
CORS: Cors;
SSL_CONF: SslConf;
PROVIDER: ProviderSession;
STORE: StoreConf;
CLEAN_STORE: CleanStoreConf;
DATABASE: Database;
RABBITMQ: Rabbitmq;
SQS: Sqs;
@ -282,22 +264,6 @@ export class ConfigService {
PORT: process.env?.PROVIDER_PORT || '5656',
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: {
CONNECTION: {
URI: process.env.DATABASE_CONNECTION_URI || '',