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
This commit is contained in:
Harry Adel 2026-02-01 00:54:38 +02:00
parent 2f6e34c5f5
commit 71eb01e233
81 changed files with 2218 additions and 2148 deletions

View file

@ -27,14 +27,14 @@ if (Meteor.isServer) {
* @param {string} boardId the ID of the board we are exporting
* @param {string} authToken the loginToken
*/
JsonRoutes.add('get', '/api/boards/:boardId/export', function (req, res) {
JsonRoutes.add('get', '/api/boards/:boardId/export', async function (req, res) {
const boardId = req.params.boardId;
let user = null;
let impersonateDone = false;
let adminId = null;
// First check if board exists and is public to avoid unnecessary authentication
const board = ReactiveCache.getBoard(boardId);
const board = await ReactiveCache.getBoard(boardId);
if (!board) {
JsonRoutes.sendResult(res, 404);
return;
@ -46,7 +46,7 @@ if (Meteor.isServer) {
const exporter = new Exporter(boardId);
JsonRoutes.sendResult(res, {
code: 200,
data: exporter.build(),
data: await exporter.build(),
});
return;
}
@ -64,18 +64,18 @@ if (Meteor.isServer) {
}
const hashToken = Accounts._hashLoginToken(loginToken);
user = ReactiveCache.getUser({
user = await ReactiveCache.getUser({
'services.resume.loginTokens.hashedToken': hashToken,
});
adminId = user._id.toString();
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
impersonateDone = await ReactiveCache.getImpersonatedUser({ adminId: adminId });
} else if (!Meteor.settings.public.sandstorm) {
Authentication.checkUserId(req.userId);
user = ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
user = await ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
}
const exporter = new Exporter(boardId);
if (exporter.canExport(user) || impersonateDone) {
if (await exporter.canExport(user) || impersonateDone) {
if (impersonateDone) {
ImpersonatedUsers.insert({
adminId: adminId,
@ -86,7 +86,7 @@ if (Meteor.isServer) {
JsonRoutes.sendResult(res, {
code: 200,
data: exporter.build(),
data: await exporter.build(),
});
} else {
// we could send an explicit error message, but on the other hand the only
@ -118,7 +118,7 @@ if (Meteor.isServer) {
JsonRoutes.add(
'get',
'/api/boards/:boardId/attachments/:attachmentId/export',
function (req, res) {
async function (req, res) {
const boardId = req.params.boardId;
const attachmentId = req.params.attachmentId;
let user = null;
@ -126,7 +126,7 @@ if (Meteor.isServer) {
let adminId = null;
// First check if board exists and is public to avoid unnecessary authentication
const board = ReactiveCache.getBoard(boardId);
const board = await ReactiveCache.getBoard(boardId);
if (!board) {
JsonRoutes.sendResult(res, 404);
return;
@ -138,7 +138,7 @@ if (Meteor.isServer) {
const exporter = new Exporter(boardId, attachmentId);
JsonRoutes.sendResult(res, {
code: 200,
data: exporter.build(),
data: await exporter.build(),
});
return;
}
@ -156,18 +156,18 @@ if (Meteor.isServer) {
}
const hashToken = Accounts._hashLoginToken(loginToken);
user = ReactiveCache.getUser({
user = await ReactiveCache.getUser({
'services.resume.loginTokens.hashedToken': hashToken,
});
adminId = user._id.toString();
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
impersonateDone = await ReactiveCache.getImpersonatedUser({ adminId: adminId });
} else if (!Meteor.settings.public.sandstorm) {
Authentication.checkUserId(req.userId);
user = ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
user = await ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
}
const exporter = new Exporter(boardId, attachmentId);
if (exporter.canExport(user) || impersonateDone) {
if (await exporter.canExport(user) || impersonateDone) {
if (impersonateDone) {
ImpersonatedUsers.insert({
adminId: adminId,
@ -178,7 +178,7 @@ if (Meteor.isServer) {
}
JsonRoutes.sendResult(res, {
code: 200,
data: exporter.build(),
data: await exporter.build(),
});
} else {
// we could send an explicit error message, but on the other hand the only
@ -203,14 +203,14 @@ if (Meteor.isServer) {
* @param {string} authToken the loginToken
* @param {string} delimiter delimiter to use while building export. Default is comma ','
*/
Picker.route('/api/boards/:boardId/export/csv', function (params, req, res) {
Picker.route('/api/boards/:boardId/export/csv', async function (params, req, res) {
const boardId = params.boardId;
let user = null;
let impersonateDone = false;
let adminId = null;
// First check if board exists and is public to avoid unnecessary authentication
const board = ReactiveCache.getBoard(boardId);
const board = await ReactiveCache.getBoard(boardId);
if (!board) {
res.writeHead(404);
res.end('Board not found');
@ -237,7 +237,7 @@ if (Meteor.isServer) {
// use Uint8Array to prevent from converting bytes to string
res.write(new Uint8Array([0xEF, 0xBB, 0xBF]));
}
res.write(exporter.buildCsv(params.query.delimiter, 'en'));
res.write(await exporter.buildCsv(params.query.delimiter, 'en'));
res.end();
return;
}
@ -256,21 +256,21 @@ if (Meteor.isServer) {
}
const hashToken = Accounts._hashLoginToken(loginToken);
user = ReactiveCache.getUser({
user = await ReactiveCache.getUser({
'services.resume.loginTokens.hashedToken': hashToken,
});
adminId = user._id.toString();
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
impersonateDone = await ReactiveCache.getImpersonatedUser({ adminId: adminId });
} else if (!Meteor.settings.public.sandstorm) {
Authentication.checkUserId(req.userId);
user = ReactiveCache.getUser({
user = await ReactiveCache.getUser({
_id: req.userId,
isAdmin: true,
});
}
const exporter = new Exporter(boardId);
if (exporter.canExport(user) || impersonateDone) {
if (await exporter.canExport(user) || impersonateDone) {
if (impersonateDone) {
let exportType = 'exportCSV';
if( params.query.delimiter == "\t" ) {
@ -303,7 +303,7 @@ if (Meteor.isServer) {
// use Uint8Array to prevent from converting bytes to string
res.write(new Uint8Array([0xEF, 0xBB, 0xBF]));
}
res.write(exporter.buildCsv(params.query.delimiter, userLanguage));
res.write(await exporter.buildCsv(params.query.delimiter, userLanguage));
res.end();
} else {
res.writeHead(403);