const express = require('express');
const router = express.Router();
const { authenticateToken } = require('../middleware/auth');
const { requireAdmin } = require('../middleware/roleCheck');
const ctrl = require('../controllers/announcement.controller');

// Agent-Callback (kein JWT, nur X-Agent-Key)
router.post('/:id/ack-agent', ctrl.agentAck);

router.use(authenticateToken);
router.get('/active',    ctrl.getActive);   // alle eingeloggten User (Notification Bell)
router.post('/:id/ack',  ctrl.userAck);     // Web-User bestätigt Ankündigung
router.get('/',          requireAdmin, ctrl.getAll);
router.post('/',         requireAdmin, ctrl.create);
router.put('/:id',       requireAdmin, ctrl.update);
router.delete('/:id',    requireAdmin, ctrl.remove);
router.get('/:id/acks',  requireAdmin, ctrl.getAcks);

module.exports = router;
