Files
wekan/models/lib/activityFeed.js
T
Lauri Ojansivu 656af74b2c An activity feed across all of a member's boards.
Member menu / "Activity on all my boards" (/activity) lists what
happened on every board the member sees in All Boards, newest first, a
page of 50 at a time: who, what - in the same sentence the notifications
use - on which card and board, and when, with the card linked. It never
carries a field's value, so an admin-only custom field cannot leak
through it; on a board where the member sees only cards assigned to
them, only those cards' activity is listed; and it is empty when the
Admin Panel hides activities or turns them off.

models/lib/activityFeed.js shapes and filters the entries;
tests/activityFeed.test.cjs covers the entry, an unseen board, the
assigned-only rule, the bound and the server's switches. Part of #2026
and #1377, with the webhook activity picker and browser push. The new
strings are English placeholders until the next translation pass.

Thanks to xet7 !
2026-10-14 15:37:31 +03:00

46 lines
1.7 KiB
JavaScript

'use strict';
// #2026 / #1377: an activity feed across all the member's boards - every
// board they see in All Boards, newest first. It carries what happened, who,
// on which card, list and board, and when - never a field's value, so an
// admin-only custom field (#3141) cannot leak through it. On a board where
// the member sees only cards assigned to them, only those cards' activity is
// in it. Pure: tests/activityFeed.test.cjs.
const MAX_LIMIT = 100;
function feedEntry(activity, { boards, cards, lists, users }) {
const board = boards.get(activity.boardId);
if (!board) return null;
const card = activity.cardId ? cards.get(activity.cardId) : null;
const list = activity.listId ? lists.get(activity.listId) : null;
const user = users.get(activity.userId);
return {
_id: activity._id,
activityType: activity.activityType,
createdAt: activity.createdAt,
boardId: board._id,
boardTitle: board.title || '',
boardSlug: board.slug || 'board',
cardId: card ? card._id : null,
cardTitle: card ? card.title || '' : '',
listTitle: list ? list.title || '' : '',
username: user ? user.username || '' : '',
};
}
// Of the activities, those this member may see in the feed.
function visibleActivities(activities, { assignedOnlyBoardIds = [], assignedCardIds = [] } = {}) {
const limited = new Set(assignedOnlyBoardIds);
const mine = new Set(assignedCardIds);
return (Array.isArray(activities) ? activities : [])
.filter(a => a && (!limited.has(a.boardId) || (a.cardId && mine.has(a.cardId))));
}
function cleanLimit(limit) {
const n = Number(limit);
return Number.isFinite(n) ? Math.max(1, Math.min(MAX_LIMIT, Math.floor(n))) : 50;
}
module.exports = { feedEntry, visibleActivities, cleanLimit, MAX_LIMIT };