Files
wekan/models/lib/boardNotificationRecipients.js
T
Lauri Ojansivu 03e8a6bf66 Honor scoped notification subscriptions and settings.
Keep muted board assignments silent while honoring explicit list and card subscriptions. Resolve notification controls against their owning settings scope and show the selected option.

Thanks to Nissulya and xet7 !

Fixes #6658,
2026-09-17 13:05:45 +03:00

28 lines
1.0 KiB
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. Explicit list/card subscriptions opt in
* to that narrower scope even when the board itself is muted. Assignment,
* mentions and BIGEVENTS_PATTERN alone must not bypass a muted board.
*/
function boardNotificationRecipients(candidates, members, boardWatchers, scopedWatchers = []) {
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),
);
scopedWatchers.forEach(userId => notifyingUserIds.add(userId));
return [...new Set(candidates || [])].filter(
userId => activeMemberIds.has(userId) && notifyingUserIds.has(userId),
);
}
module.exports = { boardNotificationRecipients };