MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / getUserChannels

Function getUserChannels

server/src/slack/client.ts:1180–1209  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

1178 * @returns Array of channel IDs the user is a member of
1179 */
1180export async function getUserChannels(userId: string): Promise<string[]> {
1181 const channelIds: string[] = [];
1182 let cursor: string | undefined;
1183
1184 do {
1185 const response = await slackRequest<{
1186 channels: Array<{ id: string; name: string }>;
1187 response_metadata?: { next_cursor?: string };
1188 }>('users.conversations', {
1189 user: userId,
1190 types: 'public_channel',
1191 exclude_archived: true,
1192 limit: 200,
1193 cursor,
1194 });
1195
1196 if (response.channels) {
1197 channelIds.push(...response.channels.map(c => c.id));
1198 }
1199
1200 cursor = response.response_metadata?.next_cursor;
1201
1202 if (cursor) {
1203 await sleep(RATE_LIMIT_DELAY_MS);
1204 }
1205 } while (cursor);
1206
1207 logger.debug({ userId, channelCount: channelIds.length }, 'Fetched user channel memberships');
1208 return channelIds;
1209}
1210
1211/**
1212 * Message from conversations.history

Callers 1

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected