mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
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,
27 lines
918 B
JavaScript
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 };
|