@@ -5,6 +5,7 @@ import { inspectSlackAccount } from "../../slack/account-inspect.js";
55import { inspectTelegramAccount } from "../../telegram/account-inspect.js" ;
66import { resolveWhatsAppAccount } from "../../web/accounts.js" ;
77import { isWhatsAppGroupJid , normalizeWhatsAppTarget } from "../../whatsapp/normalize.js" ;
8+ import { applyDirectoryQueryAndLimit , toDirectoryEntries } from "./directory-config-helpers.js" ;
89import { normalizeSlackMessagingTarget } from "./normalize/slack.js" ;
910import type { ChannelDirectoryEntry } from "./types.js" ;
1011
@@ -54,25 +55,6 @@ function normalizeTrimmedSet(
5455 . filter ( ( id ) : id is string => Boolean ( id ) ) ;
5556}
5657
57- function resolveDirectoryQuery ( query ?: string | null ) : string {
58- return query ?. trim ( ) . toLowerCase ( ) || "" ;
59- }
60-
61- function resolveDirectoryLimit ( limit ?: number | null ) : number | undefined {
62- return typeof limit === "number" && limit > 0 ? limit : undefined ;
63- }
64-
65- function applyDirectoryQueryAndLimit ( ids : string [ ] , params : DirectoryConfigParams ) : string [ ] {
66- const q = resolveDirectoryQuery ( params . query ) ;
67- const limit = resolveDirectoryLimit ( params . limit ) ;
68- const filtered = ids . filter ( ( id ) => ( q ? id . toLowerCase ( ) . includes ( q ) : true ) ) ;
69- return typeof limit === "number" ? filtered . slice ( 0 , limit ) : filtered ;
70- }
71-
72- function toDirectoryEntries ( kind : "user" | "group" , ids : string [ ] ) : ChannelDirectoryEntry [ ] {
73- return ids . map ( ( id ) => ( { kind, id } ) as const ) ;
74- }
75-
7658export async function listSlackDirectoryPeersFromConfig (
7759 params : DirectoryConfigParams ,
7860) : Promise < ChannelDirectoryEntry [ ] > {
0 commit comments