const { asyncHandler } = require('../middleware/errorHandler'); const { getDatabase } = require('../config/database'); class TeamsActivityController { /** * GET /api/teams-activity/new-channels * Returns channels discovered since last notification (notified=0). */ static getNewChannels = asyncHandler(async (req, res) => { const db = getDatabase(); const channels = db.prepare(` SELECT id, team_name, channel_name, first_seen_at FROM teams_channels WHERE notified = 0 ORDER BY first_seen_at DESC LIMIT 50 `).all(); res.json({ status: 'success', data: channels }); }); /** * POST /api/teams-activity/mark-read * Marks all unread channel notifications as read. */ static markRead = asyncHandler(async (req, res) => { const db = getDatabase(); db.prepare('UPDATE teams_channels SET notified = 1 WHERE notified = 0').run(); res.json({ status: 'success' }); }); } module.exports = TeamsActivityController;