blob: 253e15ba0e0e14bd884d3dd3d528aa77eb736a96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
},
});
|