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

Method getAllMappings

server/src/db/slack-db.ts:160–224  ·  view source on GitHub ↗

* Get all Slack user mappings

(options: {
    status?: SlackMappingStatus;
    includeBots?: boolean;
    includeDeleted?: boolean;
    search?: string;
    limit?: number;
    offset?: number;
  } = {})

Source from the content-addressed store, hash-verified

158 * Get all Slack user mappings
159 */
160 async getAllMappings(options: {
161 status?: SlackMappingStatus;
162 includeBots?: boolean;
163 includeDeleted?: boolean;
164 search?: string;
165 limit?: number;
166 offset?: number;
167 } = {}): Promise<SlackUserMapping[]> {
168 const conditions: string[] = [];
169 const params: unknown[] = [];
170 let paramIndex = 1;
171
172 if (options.status) {
173 conditions.push(`mapping_status = $${paramIndex++}`);
174 params.push(options.status);
175 }
176
177 if (!options.includeBots) {
178 conditions.push('slack_is_bot = false');
179 }
180
181 if (!options.includeDeleted) {
182 conditions.push('slack_is_deleted = false');
183 }
184
185 if (options.search) {
186 conditions.push(`(
187 slack_email ILIKE $${paramIndex} OR
188 slack_display_name ILIKE $${paramIndex} OR
189 slack_real_name ILIKE $${paramIndex}
190 )`);
191 params.push(`%${escapeLikePattern(options.search)}%`);
192 paramIndex++;
193 }
194
195 const whereClause = conditions.length > 0
196 ? `WHERE ${conditions.join(' AND ')}`
197 : '';
198
199 let sql = `
200 SELECT * FROM slack_user_mappings
201 ${whereClause}
202 ORDER BY
203 CASE WHEN mapping_status = 'mapped' THEN 0
204 WHEN mapping_status = 'pending_verification' THEN 1
205 ELSE 2
206 END,
207 slack_real_name NULLS LAST,
208 slack_display_name NULLS LAST,
209 slack_email NULLS LAST
210 `;
211
212 if (options.limit) {
213 sql += ` LIMIT $${paramIndex++}`;
214 params.push(options.limit);
215 }
216
217 if (options.offset) {

Callers 5

createAdminUsersRouterFunction · 0.95
getMappedUsersMethod · 0.95
createAdminSlackRouterFunction · 0.80
syncSlackUsersFunction · 0.80
getSyncStatusFunction · 0.80

Calls 1

escapeLikePatternFunction · 0.70

Tested by

no test coverage detected