-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: SDK delta API changes * fix: updategroupMembers * fix: test cases and minor fixes * fix: getAllGroupMembers --------- Co-authored-by: aman035 <guptaaman200115@gmail.com>
1 parent
bc4cd16
commit 76bd15c
Showing
17 changed files
with
616 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getGroupMembers } from './getGroupMembers'; | ||
import { getChatMemberCount } from './getChatMemberCount'; | ||
import { ChatMemberProfile, EnvOptionsType } from '../types'; | ||
|
||
export const getAllGroupMembers = async (options: { | ||
chatId: string; | ||
env: EnvOptionsType['env']; | ||
}): Promise<ChatMemberProfile[]> => { | ||
const { chatId, env } = options; | ||
const count = await getChatMemberCount({ chatId, env }); | ||
const overallCount = count.overallCount; | ||
const limit = 5000; | ||
const totalPages = Math.ceil(overallCount / limit); | ||
const pageNumbers = Array.from({ length: totalPages }, (_, i) => i + 1); | ||
const groupMembers: ChatMemberProfile[] = []; | ||
|
||
const memberFetchPromises = pageNumbers.map((page) => | ||
getGroupMembers({ chatId, env, page, limit }) | ||
); | ||
|
||
const membersResults = await Promise.all(memberFetchPromises); | ||
membersResults.forEach((result) => { | ||
if (result.members.length > 0) { | ||
groupMembers.push(...result.members); | ||
} | ||
}); | ||
|
||
return groupMembers; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.