Files
wekan/server/notifications/watch.js
T
Lauri Ojansivu 592d803924 Notifications feature: drop GDPR-specific wording
Disabling activities/notifications/watch can serve any law or policy, not only
GDPR. Remove GDPR mentions from the code comments and the en.i18n.json toggle
descriptions (and the Admin Panel docs), keeping the neutral #5820 reference.
2026-07-14 14:22:58 +03:00

45 lines
1.6 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { check, Match } from 'meteor/check';
import { ReactiveCache } from '/imports/reactiveCache';
import { getFeatureFlags } from '/models/lib/featureFlags';
Meteor.methods({
async watch(watchableType, id, level) {
check(watchableType, String);
check(id, String);
check(level, Match.OneOf(String, null));
// Admin Panel / Features / Notifications (#5820): the watch feature is
// disabled, so ignore any request to change a watch level.
if (getFeatureFlags().disableWatch) {
throw new Meteor.Error('error-watch-disabled');
}
const userId = this.userId;
let watchableObj = null;
let board = null;
if (watchableType === 'board') {
watchableObj = await ReactiveCache.getBoard(id);
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
board = watchableObj;
} else if (watchableType === 'list') {
watchableObj = await ReactiveCache.getList(id);
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
board = await watchableObj.board();
} else if (watchableType === 'card') {
watchableObj = await ReactiveCache.getCard(id);
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
board = await watchableObj.board();
} else {
throw new Meteor.Error('error-json-schema');
}
if (board.permission === 'private' && !board.hasMember(userId))
throw new Meteor.Error('error-board-notAMember');
await watchableObj.setWatcher(userId, level);
return true;
},
});