diff --git a/src/core/engines/gows/session.gows.core.ts b/src/core/engines/gows/session.gows.core.ts index 5894a4efa..02bb95b9e 100644 --- a/src/core/engines/gows/session.gows.core.ts +++ b/src/core/engines/gows/session.gows.core.ts @@ -239,6 +239,12 @@ enum WhatsMeowEvent { CONTACT = 'events.Contact', } +const DEFAULT_GOWS_EXCLUDE_EVENTS = [ + WhatsMeowEvent.APP_STATE, + WhatsMeowEvent.HISTORY_SYNC, + WhatsMeowEvent.CONTACT, +]; + export interface GowsConfig { connection: string; } @@ -337,12 +343,9 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { ); // Avoid having a lot of events after pairing the device // https://github.com/devlikeapro/waha/issues/1826 - // TODO: we need to make it more dynamic - const exclude = [ - WhatsMeowEvent.APP_STATE, - WhatsMeowEvent.HISTORY_SYNC, - WhatsMeowEvent.CONTACT, - ]; + const exclude = + this.sessionConfig?.gows?.excludeEvents ?? + DEFAULT_GOWS_EXCLUDE_EVENTS; const request = new messages.StreamEventsRequest({ session: this.session, exclude: exclude, diff --git a/src/structures/sessions.dto.ts b/src/structures/sessions.dto.ts index d11056f04..186b64d03 100644 --- a/src/structures/sessions.dto.ts +++ b/src/structures/sessions.dto.ts @@ -156,6 +156,18 @@ export class GowsStorageConfig { } export class GowsConfig { + @ApiProperty({ + description: + 'List of GOWS event types to exclude from the WebSocket stream.\n' + + 'By default, AppState, HistorySync, and Contact events are excluded to avoid flooding after pairing.\n' + + 'Set to an empty array to receive all events.', + required: false, + example: ['events.AppState', 'events.HistorySync', 'events.Contact'], + }) + @IsString({ each: true }) + @IsOptional() + excludeEvents?: string[]; + @ValidateNested() @Type(() => GowsStorageConfig) @IsOptional()