mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
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,
28 lines
1.0 KiB
JavaScript
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 };
|