mirror of
https://github.com/screentinker/screentinker.git
synced 2026-05-15 07:32:23 -06:00
ScreenTinker - open source digital signage management software. MIT License, all features included, no license gates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
787 B
JavaScript
28 lines
787 B
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const { getActivity, pruneActivityLog } = require('../services/activity');
|
|
|
|
// Get activity log
|
|
router.get('/', (req, res) => {
|
|
const { device_id, limit, offset } = req.query;
|
|
const isAdmin = req.user.role === 'superadmin';
|
|
|
|
const activity = getActivity({
|
|
userId: isAdmin ? null : req.user.id,
|
|
deviceId: device_id || null,
|
|
limit: Math.min(parseInt(limit) || 50, 200),
|
|
offset: parseInt(offset) || 0,
|
|
});
|
|
|
|
res.json(activity);
|
|
});
|
|
|
|
// Prune old logs (admin only)
|
|
router.delete('/prune', (req, res) => {
|
|
if (!['admin','superadmin'].includes(req.user.role)) return res.status(403).json({ error: 'Admin only' });
|
|
pruneActivityLog();
|
|
res.json({ success: true });
|
|
});
|
|
|
|
module.exports = router;
|