feat: per-board activity log
Adds an audit trail per board, visible from a new clock-icon button on the toolbar. Useful for review-style work where someone wants to see who contributed which references and when. Logged events (high-signal only — canvas-edit noise intentionally skipped): - image / video / pdf added (whether dropped, pasted, or pulled from a URL) - board created / renamed / deleted - thread started, resolved, reopened - comment posted on a thread Backend: - new activity_logs table (id, board_id, user_id, denormalised actor name + email, action, target_type/id/label, metadata JSON, created_at) with an index on (board_id, created_at DESC). - logActivity helper resolves the user once at log time and stores their display name + email so entries survive deactivation/rename. - recordActivity wraps logActivity + a Socket.IO emit to the board's room so the panel updates live without polling. - GET /api/boards/:id/activity?limit=&before= for pagination (collection-membership gated, viewer+). Frontend: - ActivityPanel side-drawer: time-grouped feed (Today / Yesterday / older), per-action icons + tone colours (add/remove/edit/comment), pagination via "Load older", live append on Socket.IO 'activity:new'. - Relative timestamps refresh every 30s. - Wired into Editor + Toolbar. README updated; roadmap entry checked off.
This commit is contained in:
@@ -18,6 +18,7 @@ const {
|
||||
getUserById,
|
||||
} = require('../db');
|
||||
const { hasCollectionRole, resolveBoard } = require('./board-access');
|
||||
const { recordActivity } = require('../activity');
|
||||
|
||||
function resolveAuthorName(reqUser) {
|
||||
if (reqUser.display_name || reqUser.username) {
|
||||
@@ -108,6 +109,14 @@ router.post('/:boardId/threads', (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
recordActivity(req, {
|
||||
boardId: req.params.boardId,
|
||||
action: 'thread.created',
|
||||
targetType: 'thread',
|
||||
targetId: threadId,
|
||||
targetLabel: content.trim().slice(0, 80),
|
||||
});
|
||||
|
||||
return res.status(201).json({ thread, comment });
|
||||
} catch (err) {
|
||||
console.error('[threads] create error:', err);
|
||||
@@ -144,6 +153,15 @@ router.patch('/:boardId/threads/:threadId', (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (status === 'resolved' || status === 'open') {
|
||||
recordActivity(req, {
|
||||
boardId: req.params.boardId,
|
||||
action: status === 'resolved' ? 'thread.resolved' : 'thread.reopened',
|
||||
targetType: 'thread',
|
||||
targetId: req.params.threadId,
|
||||
});
|
||||
}
|
||||
|
||||
return res.json({ thread: updated });
|
||||
} catch (err) {
|
||||
console.error('[threads] status error:', err);
|
||||
@@ -221,6 +239,14 @@ router.post('/:boardId/threads/:threadId/comments', (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
recordActivity(req, {
|
||||
boardId: req.params.boardId,
|
||||
action: 'comment.added',
|
||||
targetType: 'thread',
|
||||
targetId: req.params.threadId,
|
||||
targetLabel: content.trim().slice(0, 80),
|
||||
});
|
||||
|
||||
return res.status(201).json({ comment });
|
||||
} catch (err) {
|
||||
console.error('[threads] add comment error:', err);
|
||||
|
||||
Reference in New Issue
Block a user