mirror of
https://github.com/wekan/wekan.git
synced 2026-01-30 21:25:17 +01:00
Move every Boards.findOne(boardId) to the ReactiveCache (Part 2)
This commit is contained in:
parent
9022e9949f
commit
a182482cfb
37 changed files with 166 additions and 127 deletions
|
|
@ -1,16 +1,17 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Actions = new Mongo.Collection('actions');
|
||||
|
||||
Actions.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
// Activities don't need a schema because they are always set from the a trusted
|
||||
// environment - the server - and there is no risk that a user change the logic
|
||||
// we use with this collection. Moreover using a schema for this collection
|
||||
|
|
@ -12,10 +14,10 @@ Activities = new Mongo.Collection('activities');
|
|||
|
||||
Activities.helpers({
|
||||
board() {
|
||||
return Boards.findOne(this.boardId);
|
||||
return ReactiveCache.getBoard(this.boardId);
|
||||
},
|
||||
oldBoard() {
|
||||
return Boards.findOne(this.oldBoardId);
|
||||
return ReactiveCache.getBoard(this.oldBoardId);
|
||||
},
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
|
|
@ -108,7 +110,7 @@ if (Meteor.isServer) {
|
|||
let participants = [];
|
||||
let watchers = [];
|
||||
let title = 'act-activity-notify';
|
||||
const board = Boards.findOne(activity.boardId);
|
||||
const board = ReactiveCache.getBoard(activity.boardId);
|
||||
const description = `act-${activity.activityType}`;
|
||||
const params = {
|
||||
activityId: activity._id,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { FilesCollection } from 'meteor/ostrio:files';
|
||||
import { isFileValid } from './fileValidation';
|
||||
|
|
@ -122,7 +123,7 @@ Attachments = new FilesCollection({
|
|||
return false;
|
||||
}
|
||||
|
||||
const board = Boards.findOne(fileObj.meta.boardId);
|
||||
const board = ReactiveCache.getBoard(fileObj.meta.boardId);
|
||||
if (board.isPublic()) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -134,13 +135,13 @@ Attachments = new FilesCollection({
|
|||
if (Meteor.isServer) {
|
||||
Attachments.allow({
|
||||
insert(userId, fileObj) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
|
||||
},
|
||||
update(userId, fileObj) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
|
||||
},
|
||||
remove(userId, fileObj) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
|
||||
},
|
||||
fetch: ['meta'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
const storeName = 'attachments';
|
||||
const defaultStoreOptions = {
|
||||
beforeWrite: fileObj => {
|
||||
|
|
@ -35,19 +37,19 @@ if (Meteor.isServer) {
|
|||
|
||||
AttachmentsOld.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
// We authorize the attachment download either:
|
||||
// - if the board is public, everyone (even unconnected) can download it
|
||||
// - if the board is private, only board members can download it
|
||||
download(userId, doc) {
|
||||
const board = Boards.findOne(doc.boardId);
|
||||
const board = ReactiveCache.getBoard(doc.boardId);
|
||||
if (board.isPublic()) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import escapeForRegex from 'escape-string-regexp';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
import {
|
||||
|
|
@ -1124,7 +1125,7 @@ Boards.helpers({
|
|||
},
|
||||
|
||||
getDefaultSubtasksBoard() {
|
||||
return Boards.findOne(this.getDefaultSubtasksBoardId());
|
||||
return ReactiveCache.getBoard(this.getDefaultSubtasksBoardId());
|
||||
},
|
||||
|
||||
//Date Settings option such as received date, start date and so on.
|
||||
|
|
@ -1157,7 +1158,7 @@ Boards.helpers({
|
|||
},
|
||||
|
||||
getDefaultDateSettingsBoard() {
|
||||
return Boards.findOne(this.getDefaultDateSettingsBoardId());
|
||||
return ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId());
|
||||
},
|
||||
|
||||
getDefaultSubtasksListId() {
|
||||
|
|
@ -1696,7 +1697,7 @@ if (Meteor.isServer) {
|
|||
},
|
||||
quitBoard(boardId) {
|
||||
check(boardId, String);
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (board) {
|
||||
const userId = Meteor.userId();
|
||||
const index = board.memberIndex(userId);
|
||||
|
|
@ -1708,7 +1709,7 @@ if (Meteor.isServer) {
|
|||
},
|
||||
acceptInvite(boardId) {
|
||||
check(boardId, String);
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (!board) {
|
||||
throw new Meteor.Error('error-board-doesNotExist');
|
||||
}
|
||||
|
|
@ -1749,7 +1750,7 @@ if (Meteor.isServer) {
|
|||
Meteor.methods({
|
||||
archiveBoard(boardId) {
|
||||
check(boardId, String);
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (board) {
|
||||
const userId = Meteor.userId();
|
||||
const index = board.memberIndex(userId);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
const commentReactionSchema = new SimpleSchema({
|
||||
reactionCodepoint: {
|
||||
type: String,
|
||||
|
|
@ -49,13 +51,13 @@ CardCommentReactions.attachSchema(
|
|||
|
||||
CardCommentReactions.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import escapeForRegex from 'escape-string-regexp';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
|
|
@ -74,13 +75,13 @@ CardComments.attachSchema(
|
|||
|
||||
CardComments.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return userId === doc.userId || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return userId === doc.userId || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return userId === doc.userId || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return userId === doc.userId || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
fetch: ['userId', 'boardId'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -490,19 +490,19 @@ Cards.attachSchema(
|
|||
|
||||
Cards.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
|
||||
update(userId, doc, fields) {
|
||||
// Allow board members or logged in users if only vote get's changed
|
||||
return (
|
||||
allowIsBoardMember(userId, Boards.findOne(doc.boardId)) ||
|
||||
allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)) ||
|
||||
(_.isEqual(fields, ['vote', 'modifiedAt', 'dateLastActivity']) &&
|
||||
!!userId)
|
||||
);
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
|
@ -1093,7 +1093,7 @@ Cards.helpers({
|
|||
if (card && card.description) return card.description;
|
||||
else return null;
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board && board.description) return board.description;
|
||||
else return null;
|
||||
} else if (this.description) {
|
||||
|
|
@ -1112,7 +1112,7 @@ Cards.helpers({
|
|||
return card.members;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1134,7 +1134,7 @@ Cards.helpers({
|
|||
return card.assignees;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1150,7 +1150,7 @@ Cards.helpers({
|
|||
assignMember(memberId) {
|
||||
let ret;
|
||||
if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
ret = board.addMember(memberId);
|
||||
} else {
|
||||
ret = Cards.update(
|
||||
|
|
@ -1168,7 +1168,7 @@ Cards.helpers({
|
|||
{ $addToSet: { assignees: assigneeId } },
|
||||
);
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
return board.addAssignee(assigneeId);
|
||||
} else {
|
||||
return Cards.update(
|
||||
|
|
@ -1185,7 +1185,7 @@ Cards.helpers({
|
|||
{ $pull: { members: memberId } },
|
||||
);
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
return board.removeMember(memberId);
|
||||
} else {
|
||||
return Cards.update({ _id: this._id }, { $pull: { members: memberId } });
|
||||
|
|
@ -1199,7 +1199,7 @@ Cards.helpers({
|
|||
{ $pull: { assignees: assigneeId } },
|
||||
);
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
return board.removeAssignee(assigneeId);
|
||||
} else {
|
||||
return Cards.update(
|
||||
|
|
@ -1234,7 +1234,7 @@ Cards.helpers({
|
|||
return card.receivedAt;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1262,7 +1262,7 @@ Cards.helpers({
|
|||
return card.startAt;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1290,7 +1290,7 @@ Cards.helpers({
|
|||
return card.dueAt;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1318,7 +1318,7 @@ Cards.helpers({
|
|||
return card.endAt;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1346,7 +1346,7 @@ Cards.helpers({
|
|||
return card.isOvertime;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1374,7 +1374,7 @@ Cards.helpers({
|
|||
return card.spentTime;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1404,7 +1404,7 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else if (board && board.vote) {
|
||||
|
|
@ -1430,7 +1430,7 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else if (board && board.vote) {
|
||||
|
|
@ -1456,7 +1456,7 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else if (board && board.vote) {
|
||||
|
|
@ -1516,7 +1516,7 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else if (board && board.poker) {
|
||||
|
|
@ -1550,7 +1550,7 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else if (board && board.poker) {
|
||||
|
|
@ -1699,7 +1699,7 @@ Cards.helpers({
|
|||
return card.title;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1722,21 +1722,21 @@ Cards.helpers({
|
|||
if (card === undefined) {
|
||||
return null;
|
||||
}
|
||||
const board = Boards.findOne({ _id: card.boardId });
|
||||
const board = ReactiveCache.getBoard(card.boardId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
return board.title;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
return board.title;
|
||||
}
|
||||
} else {
|
||||
const board = Boards.findOne({ _id: this.boardId });
|
||||
const board = ReactiveCache.getBoard(this.boardId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1762,7 +1762,7 @@ Cards.helpers({
|
|||
return card.archived;
|
||||
}
|
||||
} else if (this.isLinkedBoard()) {
|
||||
const board = Boards.findOne({ _id: this.linkedId });
|
||||
const board = ReactiveCache.getBoard(this.linkedId);
|
||||
if (board === undefined) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -1967,7 +1967,7 @@ Cards.mutations({
|
|||
// This should never happen, but there was a bug that was fixed in commit
|
||||
// ea0239538a68e225c867411a4f3e0d27c158383.
|
||||
if (!swimlaneId) {
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
swimlaneId = board.getDefaultSwimline()._id;
|
||||
}
|
||||
// Move the minicard to the end of the target list
|
||||
|
|
@ -1993,7 +1993,7 @@ Cards.mutations({
|
|||
// This should never happen, but there was a bug that was fixed in commit
|
||||
// ea0239538a68e225c867411a4f3e0d27c158383.
|
||||
if (!swimlaneId) {
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
swimlaneId = board.getDefaultSwimline()._id;
|
||||
}
|
||||
listId = listId || this.listId;
|
||||
|
|
@ -2016,7 +2016,7 @@ Cards.mutations({
|
|||
// differs from the source board
|
||||
if (this.boardId !== boardId) {
|
||||
// Get label names
|
||||
const oldBoard = Boards.findOne(this.boardId);
|
||||
const oldBoard = ReactiveCache.getBoard(this.boardId);
|
||||
const oldBoardLabels = oldBoard.labels;
|
||||
const oldCardLabels = _.pluck(
|
||||
_.filter(oldBoardLabels, label => {
|
||||
|
|
@ -2025,7 +2025,7 @@ Cards.mutations({
|
|||
'name',
|
||||
);
|
||||
|
||||
const newBoard = Boards.findOne(boardId);
|
||||
const newBoard = ReactiveCache.getBoard(boardId);
|
||||
const newBoardLabels = newBoard.labels;
|
||||
const newCardLabelIds = _.pluck(
|
||||
_.filter(newBoardLabels, label => {
|
||||
|
|
@ -2683,10 +2683,10 @@ function cardMove(
|
|||
Activities.insert({
|
||||
userId,
|
||||
activityType: 'moveCardBoard',
|
||||
boardName: Boards.findOne(doc.boardId).title,
|
||||
boardName: ReactiveCache.getBoard(doc.boardId).title,
|
||||
boardId: doc.boardId,
|
||||
oldBoardId,
|
||||
oldBoardName: Boards.findOne(oldBoardId).title,
|
||||
oldBoardName: ReactiveCache.getBoard(oldBoardId).title,
|
||||
cardId: doc._id,
|
||||
swimlaneName: Swimlanes.findOne(doc.swimlaneId).title,
|
||||
swimlaneId: doc.swimlaneId,
|
||||
|
|
@ -3320,9 +3320,7 @@ if (Meteor.isServer) {
|
|||
Authentication.checkLoggedIn(req.userId);
|
||||
const paramBoardId = req.params.boardId;
|
||||
// Check user has permission to add card to the board
|
||||
const board = Boards.findOne({
|
||||
_id: paramBoardId,
|
||||
});
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const addPermission = allowIsBoardMemberCommentOnly(req.userId, board);
|
||||
Authentication.checkAdminOrCondition(req.userId, addPermission);
|
||||
const paramListId = req.params.listId;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { DataCache } from 'meteor-reactive-cache'
|
||||
|
||||
Checklists = new Mongo.Collection('checklists');
|
||||
|
|
@ -350,9 +351,7 @@ if (Meteor.isServer) {
|
|||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
// Check user has permission to add checklist to the card
|
||||
const board = Boards.findOne({
|
||||
_id: paramBoardId,
|
||||
});
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const addPermission = allowIsBoardMemberCommentOnly(req.userId, board);
|
||||
Authentication.checkAdminOrCondition(req.userId, addPermission);
|
||||
const paramCardId = req.params.cardId;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { isEmptyObject } from 'jquery';
|
||||
import Boards from './boards';
|
||||
|
||||
|
|
@ -320,7 +321,7 @@ export class CsvCreator {
|
|||
}
|
||||
// add the labels
|
||||
if (csvData[i][this.fieldIndex.labels]) {
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
for (const importedLabel of csvData[i][this.fieldIndex.labels].split(
|
||||
' ',
|
||||
)) {
|
||||
|
|
@ -387,7 +388,7 @@ export class CsvCreator {
|
|||
Meteor.settings.public &&
|
||||
Meteor.settings.public.sandstorm;
|
||||
if (isSandstorm && currentBoardId) {
|
||||
const currentBoard = Boards.findOne(currentBoardId);
|
||||
const currentBoard = ReactiveCache.getBoard(currentBoardId);
|
||||
currentBoard.archive();
|
||||
}
|
||||
this.mapHeadertoCardFieldIndex(board[0]);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
CustomFields = new Mongo.Collection('customFields');
|
||||
|
||||
/**
|
||||
|
|
@ -363,7 +365,7 @@ if (Meteor.isServer) {
|
|||
) {
|
||||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
const board = Boards.findOne({ _id: paramBoardId });
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const id = CustomFields.direct.insert({
|
||||
name: req.body.name,
|
||||
type: req.body.type,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import moment from 'moment/min/moment-with-locales';
|
||||
const Papa = require('papaparse');
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
|
|
@ -34,7 +35,7 @@ export class Exporter {
|
|||
};
|
||||
_.extend(
|
||||
result,
|
||||
Boards.findOne(this._boardId, {
|
||||
ReactiveCache.getBoard(this._boardId, {
|
||||
fields: {
|
||||
stars: 0,
|
||||
},
|
||||
|
|
@ -379,7 +380,7 @@ export class Exporter {
|
|||
}
|
||||
|
||||
canExport(user) {
|
||||
const board = Boards.findOne(this._boardId);
|
||||
const board = ReactiveCache.getBoard(this._boardId);
|
||||
return board && board.isVisibleBy(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Integrations = new Mongo.Collection('integrations');
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +104,7 @@ const permissionHelper = {
|
|||
allow(userId, doc) {
|
||||
const user = Users.findOne(userId);
|
||||
const isAdmin = user && Meteor.user().isAdmin;
|
||||
return isAdmin || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
};
|
||||
Integrations.allow({
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { ALLOWED_COLORS } from '/config/const';
|
||||
|
||||
Lists = new Mongo.Collection('lists');
|
||||
|
|
@ -175,13 +176,13 @@ Lists.attachSchema(
|
|||
|
||||
Lists.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
|
@ -269,7 +270,7 @@ Lists.helpers({
|
|||
},
|
||||
|
||||
board() {
|
||||
return Boards.findOne(this.boardId);
|
||||
return ReactiveCache.getBoard(this.boardId);
|
||||
},
|
||||
|
||||
getWipLimit(option) {
|
||||
|
|
@ -559,7 +560,7 @@ if (Meteor.isServer) {
|
|||
try {
|
||||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
const board = Boards.findOne(paramBoardId);
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const id = Lists.insert({
|
||||
title: req.body.title,
|
||||
boardId: paramBoardId,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Rules = new Mongo.Collection('rules');
|
||||
|
|
@ -63,7 +64,7 @@ Rules.helpers({
|
|||
return Triggers.findOne({ _id: this.triggerId });
|
||||
},
|
||||
board() {
|
||||
return Boards.findOne({ _id: this.boardId });
|
||||
return ReactiveCache.getBoard(this.boardId);
|
||||
},
|
||||
trigger() {
|
||||
return Triggers.findOne({ _id: this.triggerId });
|
||||
|
|
@ -75,13 +76,13 @@ Rules.helpers({
|
|||
|
||||
Rules.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { ALLOWED_COLORS } from '/config/const';
|
||||
|
||||
Swimlanes = new Mongo.Collection('swimlanes');
|
||||
|
|
@ -111,13 +112,13 @@ Swimlanes.attachSchema(
|
|||
|
||||
Swimlanes.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
fetch: ['boardId'],
|
||||
});
|
||||
|
|
@ -235,7 +236,7 @@ Swimlanes.helpers({
|
|||
},
|
||||
|
||||
board() {
|
||||
return Boards.findOne(this.boardId);
|
||||
return ReactiveCache.getBoard(this.boardId);
|
||||
},
|
||||
|
||||
colorClass() {
|
||||
|
|
@ -469,7 +470,7 @@ if (Meteor.isServer) {
|
|||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
|
||||
const board = Boards.findOne(paramBoardId);
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const id = Swimlanes.insert({
|
||||
title: req.body.title,
|
||||
boardId: paramBoardId,
|
||||
|
|
@ -504,7 +505,7 @@ if (Meteor.isServer) {
|
|||
const paramBoardId = req.params.boardId;
|
||||
const paramSwimlaneId = req.params.swimlaneId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
const board = Boards.findOne(paramBoardId);
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const swimlane = Swimlanes.findOne({
|
||||
_id: paramSwimlaneId,
|
||||
boardId: paramBoardId,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import moment from 'moment/min/moment-with-locales';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
|
||||
|
|
@ -753,7 +754,7 @@ export class TrelloCreator {
|
|||
Meteor.settings.public &&
|
||||
Meteor.settings.public.sandstorm;
|
||||
if (isSandstorm && currentBoardId) {
|
||||
const currentBoard = Boards.findOne(currentBoardId);
|
||||
const currentBoard = ReactiveCache.getBoard(currentBoardId);
|
||||
currentBoard.archive();
|
||||
}
|
||||
this.parseActions(board.actions);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Triggers = new Mongo.Collection('triggers');
|
||||
|
|
@ -24,13 +25,13 @@ Triggers.before.update((userId, doc, fieldNames, modifier) => {
|
|||
|
||||
Triggers.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ if (Meteor.isClient) {
|
|||
isBoardAdmin(boardId) {
|
||||
let board;
|
||||
if (boardId) {
|
||||
board = Boards.findOne(boardId);
|
||||
board = ReactiveCache.getBoard(boardId);
|
||||
} else {
|
||||
board = Utils.getCurrentBoard();
|
||||
}
|
||||
|
|
@ -1388,7 +1388,7 @@ if (Meteor.isServer) {
|
|||
check(boardId, String);
|
||||
|
||||
const inviter = Meteor.user();
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
const allowInvite =
|
||||
inviter &&
|
||||
board &&
|
||||
|
|
@ -1453,7 +1453,7 @@ if (Meteor.isServer) {
|
|||
|
||||
//Check if there is a subtasks board
|
||||
if (board.subtasksDefaultBoardId) {
|
||||
const subBoard = Boards.findOne(board.subtasksDefaultBoardId);
|
||||
const subBoard = ReactiveCache.getBoard(board.subtasksDefaultBoardId);
|
||||
//If there is, also add user to that board
|
||||
if (subBoard) {
|
||||
subBoard.addMember(user._id);
|
||||
|
|
@ -1989,7 +1989,7 @@ if (Meteor.isServer) {
|
|||
throw new Meteor.Error('error-invitation-code-not-exist');
|
||||
} else {
|
||||
invitationCode.boardsToBeInvited.forEach((boardId) => {
|
||||
const board = Boards.findOne(boardId);
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
board.addMember(doc._id);
|
||||
});
|
||||
if (!doc.profile) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import moment from 'moment/min/moment-with-locales';
|
||||
|
||||
const DateString = Match.Where(function(dateAsString) {
|
||||
|
|
@ -907,7 +908,7 @@ export class WekanCreator {
|
|||
Meteor.settings.public &&
|
||||
Meteor.settings.public.sandstorm;
|
||||
if (isSandstorm && currentBoardId) {
|
||||
const currentBoard = Boards.findOne(currentBoardId);
|
||||
const currentBoard = ReactiveCache.getBoard(currentBoardId);
|
||||
currentBoard.archive();
|
||||
}
|
||||
this.parseActivities(board);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue