Skip to content

Commit

Permalink
Merge pull request #283 from gabrielpastori1/typeboot-keep-open
Browse files Browse the repository at this point in the history
simple add keep open
  • Loading branch information
DavidsonGomes authored Dec 15, 2023
2 parents f612a45 + ff82987 commit e48cea1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ QRCODE_COLOR=#198754

# old | latest
TYPEBOT_API_VERSION=latest
TYPEBOT_KEEP_OPEN=false

# Defines an authentication type for the api
# We recommend using the apikey because it will allow you to use a custom token,
Expand Down
3 changes: 2 additions & 1 deletion src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
export type QrCode = { LIMIT: number; COLOR: string };
export type Typebot = { API_VERSION: string };
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
export type Production = boolean;

export interface Env {
Expand Down Expand Up @@ -308,6 +308,7 @@ export class ConfigService {
},
TYPEBOT: {
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
KEEP_OPEN: process.env.TYPEBOT_KEEP_OPEN === 'true',
},
AUTHENTICATION: {
TYPE: process.env.AUTHENTICATION_TYPE as 'apikey',
Expand Down
1 change: 1 addition & 0 deletions src/dev-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ QRCODE:

TYPEBOT:
API_VERSION: 'old' # old | latest
KEEP_OPEN: false

# Defines an authentication type for the api
# We recommend using the apikey because it will allow you to use a custom token,
Expand Down
3 changes: 3 additions & 0 deletions src/whatsapp/services/typebot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export class TypebotService {
private readonly eventEmitter: EventEmitter2,
) {
this.eventEmitter.on('typebot:end', async (data) => {
const keep_open = this.configService.get<Typebot>('TYPEBOT').KEEP_OPEN;
if (keep_open) return;

await this.clearSessions(data.instance, data.remoteJid);
});
}
Expand Down

0 comments on commit e48cea1

Please sign in to comment.