wekan/server/notifications/watch.js
Harry Adel 71eb01e233 Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async

Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
  checklists, checklistItems, customFields, attachments, integrations,
  cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00

35 lines
1.2 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
Meteor.methods({
async 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 = 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;
},
});