mirror of
https://github.com/wekan/wekan.git
synced 2026-03-05 05:10:15 +01:00
Add notification, allow watch boards / lists / cards
This commit is contained in:
parent
9ef8ebaf09
commit
9bbdacc79a
24 changed files with 579 additions and 16 deletions
36
server/notifications/watch.js
Normal file
36
server/notifications/watch.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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;
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue