( slackUserIds: string[], concurrency = 5 )
| 314 | * Returns a map of user ID -> display name. |
| 315 | */ |
| 316 | export async function resolveSlackUserDisplayNames( |
| 317 | slackUserIds: string[], |
| 318 | concurrency = 5 |
| 319 | ): Promise<Record<string, string>> { |
| 320 | const results: Record<string, string> = {}; |
| 321 | const uniqueIds = [...new Set(slackUserIds)]; |
| 322 | |
| 323 | // Process in batches to avoid rate limiting |
| 324 | for (let i = 0; i < uniqueIds.length; i += concurrency) { |
| 325 | const batch = uniqueIds.slice(i, i + concurrency); |
| 326 | const batchResults = await Promise.all( |
| 327 | batch.map(async (userId) => { |
| 328 | const resolved = await resolveSlackUserDisplayName(userId); |
| 329 | return { userId, displayName: resolved?.display_name }; |
| 330 | }) |
| 331 | ); |
| 332 | |
| 333 | for (const { userId, displayName } of batchResults) { |
| 334 | if (displayName) { |
| 335 | results[userId] = displayName; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return results; |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Look up a user by email address |
no test coverage detected