The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
wekan/server/notifications/watch.js

36 lines
1.1 KiB

Meteor.methods({
watch(watchableType, id, level) {
check(watchableType, String);
check(id, String);
check(level, Match.OneOf(String, null));
const userId = Meteor.userId();
let watchableObj = null;
let board = null;
if (watchableType === 'board') {
watchableObj = Boards.findOne(id);
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
board = watchableObj;
} else if (watchableType === 'list') {
watchableObj = Lists.findOne(id);
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
board = watchableObj.board();
} else if (watchableType === 'card') {
watchableObj = Cards.findOne(id);
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
board = watchableObj.board();
} else {
throw new Meteor.Error('error-json-schema');
}
if ((board.permission === 'private') && !board.hasMember(userId))
throw new Meteor.Error('error-board-notAMember');
watchableObj.setWatcher(userId, level);
return true;
},
});