From e8a09ec2705d7a7ac88015bcdc2a649a2602251f Mon Sep 17 00:00:00 2001 From: alina sireneva Date: Sun, 5 May 2024 20:56:52 +0300 Subject: [PATCH] feat(core): broadcast_only flag for searchGlobal --- .../src/highlevel/methods/messages/iter-search-global.ts | 3 ++- .../core/src/highlevel/methods/messages/search-global.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/highlevel/methods/messages/iter-search-global.ts b/packages/core/src/highlevel/methods/messages/iter-search-global.ts index 55ee704a..b431cf42 100644 --- a/packages/core/src/highlevel/methods/messages/iter-search-global.ts +++ b/packages/core/src/highlevel/methods/messages/iter-search-global.ts @@ -33,7 +33,7 @@ export async function* iterSearchGlobal( ): AsyncIterableIterator { if (!params) params = {} - const { query = '', filter = SearchFilters.Empty, limit = Infinity, chunkSize = 100 } = params + const { query = '', filter = SearchFilters.Empty, limit = Infinity, chunkSize = 100, onlyChannels } = params const minDate = normalizeDate(params.minDate) ?? 0 const maxDate = normalizeDate(params.maxDate) ?? 0 @@ -49,6 +49,7 @@ export async function* iterSearchGlobal( minDate, maxDate, offset, + onlyChannels, }) if (!res.length) return diff --git a/packages/core/src/highlevel/methods/messages/search-global.ts b/packages/core/src/highlevel/methods/messages/search-global.ts index db12fa5f..40265b44 100644 --- a/packages/core/src/highlevel/methods/messages/search-global.ts +++ b/packages/core/src/highlevel/methods/messages/search-global.ts @@ -63,6 +63,11 @@ export async function searchGlobal( * Only return messages older than this date */ maxDate?: Date | number + + /** + * Whether to only search across broadcast channels + */ + onlyChannels?: boolean }, ): Promise> { if (!params) params = {} @@ -72,6 +77,7 @@ export async function searchGlobal( filter = SearchFilters.Empty, limit = 100, offset: { rate: offsetRate, peer: offsetPeer, id: offsetId } = defaultOffset, + onlyChannels, } = params const minDate = normalizeDate(params.minDate) ?? 0 @@ -87,6 +93,7 @@ export async function searchGlobal( offsetRate, offsetPeer, limit, + broadcastsOnly: onlyChannels, }) assertTypeIsNot('searchGlobal', res, 'messages.messagesNotModified')