Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple add keep open #283

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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