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

Function createAdminSlackRouter

server/src/routes/admin/slack.ts:29–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 * Returns a router to be mounted at /api/admin/slack
28 */
29export function createAdminSlackRouter(): Router {
30 const router = Router();
31
32 // GET /api/admin/slack/status - Get Slack integration status
33 router.get('/status', requireAuth, requireAdmin, async (req, res) => {
34 try {
35 const configured = isSlackConfigured();
36 let connection = null;
37
38 if (configured) {
39 connection = await testSlackConnection();
40 }
41
42 const syncStatus = await getSyncStatus();
43
44 res.json({
45 configured,
46 connection,
47 stats: syncStatus.stats,
48 last_sync: syncStatus.last_sync,
49 });
50 } catch (error) {
51 logger.error({ err: error }, 'Get Slack status error');
52 res.status(500).json({
53 error: 'Failed to get Slack status',
54 });
55 }
56 });
57
58 // GET /api/admin/slack/stats - Get Slack mapping statistics
59 router.get('/stats', requireAuth, requireAdmin, async (req, res) => {
60 try {
61 const stats = await slackDb.getStats();
62 res.json(stats);
63 } catch (error) {
64 logger.error({ err: error }, 'Get Slack stats error');
65 res.status(500).json({
66 error: 'Failed to get Slack stats',
67 });
68 }
69 });
70
71 // POST /api/admin/slack/sync - Trigger user sync from Slack
72 router.post('/sync', requireAuth, requireAdmin, async (req, res) => {
73 try {
74 const result = await syncSlackUsers();
75 logger.info(result, 'Slack user sync completed');
76 // Invalidate caches since mappings may have changed
77 invalidateUnifiedUsersCache();
78 invalidateMemberContextCache(); // Clear all - bulk sync affects many users
79 res.json(result);
80 } catch (error) {
81 logger.error({ err: error }, 'Slack sync error');
82 res.status(500).json({
83 error: 'Failed to sync Slack users',
84 });
85 }
86 });

Callers 1

setupRoutesMethod · 0.85

Calls 15

isSlackConfiguredFunction · 0.85
testSlackConnectionFunction · 0.85
getSyncStatusFunction · 0.85
syncSlackUsersFunction · 0.85
buildAaoEmailToUserIdMapFunction · 0.85
getAllMappingsMethod · 0.80
getBySlackUserIdMethod · 0.80

Tested by

no test coverage detected