Skip to content

Commit

Permalink
Merge pull request #461 from judsonjuniorr/refactor/temp_delete_option
Browse files Browse the repository at this point in the history
Refactor/temp delete option
  • Loading branch information
DavidsonGomes authored Mar 7, 2024
2 parents 060af66 + a6adbd6 commit f5df8bc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_BAILEYS=error
# Default time: 5 minutes
# If you don't even want an expiration, enter the value false
DEL_INSTANCE=false
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start

# Temporary data storage
STORE_MESSAGES=true
Expand Down
1 change: 1 addition & 0 deletions Docker/evolution-api-all-services/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_BAILEYS=error
# Default time: 5 minutes
# If you don't even want an expiration, enter the value false
DEL_INSTANCE=false
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start

# Temporary data storage
STORE_MESSAGES=true
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ENV LOG_COLOR=true
ENV LOG_BAILEYS=error

ENV DEL_INSTANCE=false
ENV DEL_TEMP_INSTANCES=true

ENV STORE_MESSAGES=true
ENV STORE_MESSAGE_UP=true
Expand Down
4 changes: 4 additions & 0 deletions src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export interface Env {
WA_BUSINESS: WaBusiness;
LOG: Log;
DEL_INSTANCE: DelInstance;
DEL_TEMP_INSTANCES: boolean;
LANGUAGE: Language;
WEBHOOK: Webhook;
CONFIG_SESSION_PHONE: ConfigSessionPhone;
Expand Down Expand Up @@ -317,6 +318,9 @@ export class ConfigService {
DEL_INSTANCE: isBooleanString(process.env?.DEL_INSTANCE)
? process.env.DEL_INSTANCE === 'true'
: Number.parseInt(process.env.DEL_INSTANCE) || false,
DEL_TEMP_INSTANCES: isBooleanString(process.env?.DEL_TEMP_INSTANCES)
? process.env.DEL_TEMP_INSTANCES === 'true'
: true,
LANGUAGE: process.env?.LANGUAGE || 'en',
WEBHOOK: {
GLOBAL: {
Expand Down
1 change: 1 addition & 0 deletions src/dev-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ LOG:
# Default time: 5 minutes
# If you don't even want an expiration, enter the value false
DEL_INSTANCE: false # or false
DEL_TEMP_INSTANCES: true # Delete instances with status closed on start

# Temporary data storage
STORE:
Expand Down
5 changes: 5 additions & 0 deletions src/whatsapp/services/monitor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ export class WAMonitoringService {
}

private async deleteTempInstances(collections: Collection<Document>[]) {
const shouldDelete = this.configService.get<boolean>('DEL_TEMP_INSTANCES');
if (!shouldDelete) {
this.logger.verbose('Temp instances deletion is disabled');
return;
}
this.logger.verbose('Cleaning up temp instances');
const auths = await this.repository.auth.list();
if (auths.length === 0) {
Expand Down

0 comments on commit f5df8bc

Please sign in to comment.