2023-01-14 13:29:57 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
|
|
2016-01-05 23:26:02 +08:00
|
|
|
Meteor.methods({
|
2026-01-21 19:22:54 +02:00
|
|
|
async watch(watchableType, id, level) {
|
2016-01-05 23:26:02 +08:00
|
|
|
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') {
|
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
|
|
|
watchableObj = await ReactiveCache.getBoard(id);
|
2016-01-05 23:26:02 +08:00
|
|
|
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
|
|
|
|
|
board = watchableObj;
|
|
|
|
|
} else if (watchableType === 'list') {
|
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
|
|
|
watchableObj = await ReactiveCache.getList(id);
|
2016-01-05 23:26:02 +08:00
|
|
|
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
|
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
|
|
|
board = await watchableObj.board();
|
2016-01-05 23:26:02 +08:00
|
|
|
} else if (watchableType === 'card') {
|
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
|
|
|
watchableObj = await ReactiveCache.getCard(id);
|
2016-01-05 23:26:02 +08:00
|
|
|
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
|
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
|
|
|
board = await watchableObj.board();
|
2016-01-05 23:26:02 +08:00
|
|
|
} else {
|
|
|
|
|
throw new Meteor.Error('error-json-schema');
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-28 12:52:09 -05:00
|
|
|
if (board.permission === 'private' && !board.hasMember(userId))
|
2016-01-05 23:26:02 +08:00
|
|
|
throw new Meteor.Error('error-board-notAMember');
|
|
|
|
|
|
2026-01-21 19:22:54 +02:00
|
|
|
await watchableObj.setWatcher(userId, level);
|
2016-01-05 23:26:02 +08:00
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
});
|