Files
wekan/models/lib/boardNotificationRecipients.js
T
Lauri Ojansivu 4be77e7189 Honor muted boards for every notification source
Apply the board watch level at the final recipient boundary so direct assignments, mentions, card or list watchers, and broad-event notifications cannot send mail or profile notifications to muted users. Keep Watching and Tracking active members eligible, and cover missing/default-muted, inactive and non-member recipients.

Thanks to Nissulya and xet7 !

Fixes #6658,
2026-08-31 13:27:15 +03:00

27 lines
918 B
JavaScript

'use strict';
const NOTIFYING_LEVELS = new Set(['watching', 'tracking']);
/**
* Keep notification candidates who are active board members and whose board
* watch level permits notifications. A missing watcher entry has the board's
* default `muted` meaning and must not be bypassed by assignment, mentions,
* card/list watching or BIGEVENTS_PATTERN.
*/
function boardNotificationRecipients(candidates, members, boardWatchers) {
const activeMemberIds = new Set(
(members || []).filter(member => member.isActive === true).map(member => member.userId),
);
const notifyingUserIds = new Set(
(boardWatchers || [])
.filter(watcher => NOTIFYING_LEVELS.has(watcher.level))
.map(watcher => watcher.userId),
);
return [...new Set(candidates || [])].filter(
userId => activeMemberIds.has(userId) && notifyingUserIds.has(userId),
);
}
module.exports = { boardNotificationRecipients };