Skip to content
Open
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
15 changes: 9 additions & 6 deletions src/core/engines/gows/session.gows.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/structures/sessions.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down