mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
The all-boards activity feed showed "checked __checklistItem__ of checklist __checklist__", "from list __oldList__ at swimlane __oldSwimlane__", "added attachment __attachment__", an empty "at swimlane", and raw names such as "removedChecklistItem": it filled only the card, list and board of the notification sentence. - server/activityFeed.js reads the ids the sentence needs and looks the names up a batch at a time: swimlanes, old list and swimlane, checklist and item, attachment, label, member and assignee, comment, old board. Never a field's value (an admin-only custom field stays out), a comment's text only for a member who may read comments, and another board only when the member sees it too. - A rename or a restore names its new title itself, and a swimlane's activity keeps the swimlane's id in listId; activityTitleParams fills those for the feed and the notifications alike. - A placeholder nothing could fill - a deleted checklist item - is left out instead of shown as __name__. - Ten kinds of activity had no sentence at all, in the feed or in notifications: removedChecklistItem, moveCardBoard, deleteBoard, the board, list and swimlane renames and restores, joinAssignee and unjoinAssignee. They have one now, translated in all locales; the restores, moves and checklist ones join their notification groups. tests/activityFeed.test.cjs fills every name, refuses comments and hidden boards, and fails on any stored activity type without a sentence; activity-feed-sentences.e2e.js checks the feed shows the names and no __placeholder__. Thanks to xet7 !
54 lines
2.5 KiB
JavaScript
54 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
// wekan/wekan#572 (maintainer decision 2026-09-29): per-activity notification
|
|
// options. The 3-tier Notification Settings (models/lib/notificationSettings.js)
|
|
// choose WHERE a notification goes - the bell and email. These choose WHICH
|
|
// kinds of card activity a member is told about at all: somebody who does not
|
|
// want a notification every time a label is added can turn off "Labels" and
|
|
// keep everything else.
|
|
//
|
|
// Muting is the member's own choice (profile.notifyMutedActivities, a list of
|
|
// the keys below); an empty list is the old behaviour. Due-date reminders and
|
|
// @mentions are never muted here: a reminder has its own per-board setting
|
|
// (#5323), and a mention is addressed to the member by name.
|
|
|
|
const NOTIFICATION_ACTIVITY_GROUPS = {
|
|
labels: ['addedLabel', 'removedLabel'],
|
|
members: ['joinMember', 'unjoinMember', 'addBoardMember', 'removeBoardMember'],
|
|
assignees: ['joinAssignee', 'unjoinAssignee'],
|
|
comments: ['addComment', 'editComment', 'deleteComment'],
|
|
moves: ['moveCard', 'moveCardToOtherBoard', 'moveCardBoard'],
|
|
dates: ['a-dueAt', 'a-endAt', 'a-startAt', 'a-receivedAt'],
|
|
checklists: ['addChecklist', 'addChecklistItem', 'removeChecklist', 'removeChecklistItem', 'removedChecklistItem',
|
|
'checkedItem', 'uncheckedItem', 'completeChecklist', 'uncompleteChecklist'],
|
|
attachments: ['addAttachment', 'deleteAttachment'],
|
|
customFields: ['setCustomField'],
|
|
archive: ['archivedCard', 'restoredCard', 'archivedList', 'archivedSwimlane', 'deleteCard', 'restoredList',
|
|
'restoredSwimlane'],
|
|
created: ['createCard', 'createList', 'createSwimlane', 'addSubtask', 'importCard', 'importList'],
|
|
};
|
|
|
|
const GROUP_KEYS = Object.keys(NOTIFICATION_ACTIVITY_GROUPS);
|
|
|
|
// The group an activity type belongs to, or null (never muted).
|
|
function notificationGroupOf(activityType) {
|
|
for (const key of GROUP_KEYS) {
|
|
if (NOTIFICATION_ACTIVITY_GROUPS[key].includes(activityType)) return key;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Keep only known keys, once each, in catalog order.
|
|
function cleanMutedGroups(value) {
|
|
const list = Array.isArray(value) ? value : [];
|
|
return GROUP_KEYS.filter(key => list.includes(key));
|
|
}
|
|
|
|
// Has this member muted notifications about this kind of activity?
|
|
function isActivityMuted(activityType, mutedGroups) {
|
|
const group = notificationGroupOf(activityType);
|
|
return !!group && cleanMutedGroups(mutedGroups).includes(group);
|
|
}
|
|
|
|
module.exports = { NOTIFICATION_ACTIVITY_GROUPS, GROUP_KEYS, notificationGroupOf, cleanMutedGroups, isActivityMuted };
|