feat: Logs zeigen jetzt auch Besuche oeffentlicher Links (IP+Ort), Dropdown-Filter ergaenzt, Logs erfassen jetzt auch Upload-Freigabe und Datei-Teilen Besuche, Filter-Dropdown erweitert
This commit is contained in:
@@ -524,4 +524,50 @@ router.get('/push-logs', authenticate, requireAdmin, (req, res) => {
|
||||
res.json(logs);
|
||||
});
|
||||
|
||||
// GET /logs – kombinierte Übersicht: Pushover-Nachrichten + Besuche
|
||||
// öffentlicher Links, für den Logs-Bereich mit Filter-Dropdown (Admin)
|
||||
router.get('/logs', authenticate, requireAdmin, (req, res) => {
|
||||
const limit = Math.min(parseInt(req.query.limit) || 200, 1000);
|
||||
|
||||
const pushRows = db.prepare(`
|
||||
SELECT pl.id, pl.user_id, u.username, pl.title, pl.message, pl.priority,
|
||||
pl.source, pl.success, pl.created_at
|
||||
FROM push_log pl
|
||||
LEFT JOIN users u ON u.id = pl.user_id
|
||||
ORDER BY pl.id DESC
|
||||
LIMIT ?
|
||||
`).all(limit).map(r => ({
|
||||
logType: 'pushover',
|
||||
id: `push-${r.id}`,
|
||||
created_at: r.created_at,
|
||||
username: r.username,
|
||||
title: r.title,
|
||||
message: r.message,
|
||||
priority: r.priority,
|
||||
source: r.source,
|
||||
success: !!r.success,
|
||||
}));
|
||||
|
||||
const accessRows = db.prepare(`
|
||||
SELECT id, link_type, path, ip, location, created_at
|
||||
FROM public_access_log
|
||||
ORDER BY id DESC
|
||||
LIMIT ?
|
||||
`).all(limit).map(r => ({
|
||||
logType: 'public_access',
|
||||
id: `access-${r.id}`,
|
||||
created_at: r.created_at,
|
||||
linkType: r.link_type,
|
||||
path: r.path,
|
||||
ip: r.ip,
|
||||
location: r.location,
|
||||
}));
|
||||
|
||||
const combined = [...pushRows, ...accessRows]
|
||||
.sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''))
|
||||
.slice(0, limit);
|
||||
|
||||
res.json(combined);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user