mirror of
https://github.com/wekan/wekan.git
synced 2026-02-20 23:14:07 +01:00
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:
parent
2f6e34c5f5
commit
71eb01e233
81 changed files with 2218 additions and 2148 deletions
|
|
@ -101,21 +101,21 @@ Integrations.Const = {
|
|||
},
|
||||
};
|
||||
const permissionHelper = {
|
||||
allow(userId, doc) {
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
const isAdmin = user && ReactiveCache.getCurrentUser().isAdmin;
|
||||
return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
async allow(userId, doc) {
|
||||
const user = await ReactiveCache.getUser(userId);
|
||||
const isAdmin = user && (await ReactiveCache.getCurrentUser()).isAdmin;
|
||||
return isAdmin || allowIsBoardAdmin(userId, await ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
};
|
||||
Integrations.allow({
|
||||
insert(userId, doc) {
|
||||
return permissionHelper.allow(userId, doc);
|
||||
async insert(userId, doc) {
|
||||
return await permissionHelper.allow(userId, doc);
|
||||
},
|
||||
update(userId, doc) {
|
||||
return permissionHelper.allow(userId, doc);
|
||||
async update(userId, doc) {
|
||||
return await permissionHelper.allow(userId, doc);
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return permissionHelper.allow(userId, doc);
|
||||
async remove(userId, doc) {
|
||||
return await permissionHelper.allow(userId, doc);
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
|
@ -134,7 +134,7 @@ if (Meteor.isServer) {
|
|||
* @param {string} boardId the board ID
|
||||
* @return_type [Integrations]
|
||||
*/
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/integrations', function(
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/integrations', async function(
|
||||
req,
|
||||
res,
|
||||
) {
|
||||
|
|
@ -142,10 +142,10 @@ if (Meteor.isServer) {
|
|||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
|
||||
const data = ReactiveCache.getIntegrations(
|
||||
const data = (await ReactiveCache.getIntegrations(
|
||||
{ boardId: paramBoardId },
|
||||
{ fields: { token: 0 } },
|
||||
).map(function(doc) {
|
||||
)).map(function(doc) {
|
||||
return doc;
|
||||
});
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ if (Meteor.isServer) {
|
|||
* @param {string} intId the integration ID
|
||||
* @return_type Integrations
|
||||
*/
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/integrations/:intId', function(
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/integrations/:intId', async function(
|
||||
req,
|
||||
res,
|
||||
) {
|
||||
|
|
@ -177,7 +177,7 @@ if (Meteor.isServer) {
|
|||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: ReactiveCache.getIntegration(
|
||||
data: await ReactiveCache.getIntegration(
|
||||
{ _id: paramIntId, boardId: paramBoardId },
|
||||
{ fields: { token: 0 } },
|
||||
),
|
||||
|
|
@ -310,7 +310,7 @@ if (Meteor.isServer) {
|
|||
JsonRoutes.add(
|
||||
'DELETE',
|
||||
'/api/boards/:boardId/integrations/:intId/activities',
|
||||
function(req, res) {
|
||||
async function(req, res) {
|
||||
try {
|
||||
const paramBoardId = req.params.boardId;
|
||||
const paramIntId = req.params.intId;
|
||||
|
|
@ -324,7 +324,7 @@ if (Meteor.isServer) {
|
|||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: ReactiveCache.getIntegration(
|
||||
data: await ReactiveCache.getIntegration(
|
||||
{ _id: paramIntId, boardId: paramBoardId },
|
||||
{ fields: { _id: 1, activities: 1 } },
|
||||
),
|
||||
|
|
@ -350,7 +350,7 @@ if (Meteor.isServer) {
|
|||
JsonRoutes.add(
|
||||
'POST',
|
||||
'/api/boards/:boardId/integrations/:intId/activities',
|
||||
function(req, res) {
|
||||
async function(req, res) {
|
||||
try {
|
||||
const paramBoardId = req.params.boardId;
|
||||
const paramIntId = req.params.intId;
|
||||
|
|
@ -364,7 +364,7 @@ if (Meteor.isServer) {
|
|||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: ReactiveCache.getIntegration(
|
||||
data: await ReactiveCache.getIntegration(
|
||||
{ _id: paramIntId, boardId: paramBoardId },
|
||||
{ fields: { _id: 1, activities: 1 } },
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue