Move every Boards.findOne(boardId) to the ReactiveCache (Part 2)

pull/5014/head
Martin Filser 2 years ago
parent 9022e9949f
commit a182482cfb
  1. 3
      client/components/activities/activities.js
  2. 9
      client/components/boards/boardsList.js
  3. 3
      client/components/cards/cardDetails.js
  4. 5
      client/components/cards/checklists.js
  5. 4
      client/components/cards/subtasks.js
  6. 14
      client/components/lists/listBody.js
  7. 5
      client/components/settings/attachments.js
  8. 3
      client/components/sidebar/sidebar.js
  9. 10
      client/lib/dialogWithBoardSwimlaneList.js
  10. 6
      client/lib/keyboard.js
  11. 4
      client/lib/utils.js
  12. 7
      models/actions.js
  13. 8
      models/activities.js
  14. 9
      models/attachments.js
  15. 10
      models/attachments_old.js
  16. 11
      models/boards.js
  17. 8
      models/cardCommentReactions.js
  18. 7
      models/cardComments.js
  19. 68
      models/cards.js
  20. 5
      models/checklists.js
  21. 5
      models/csvCreator.js
  22. 4
      models/customFields.js
  23. 5
      models/exporter.js
  24. 4
      models/integrations.js
  25. 11
      models/lists.js
  26. 9
      models/rules.js
  27. 13
      models/swimlanes.js
  28. 3
      models/trelloCreator.js
  29. 7
      models/triggers.js
  30. 8
      models/users.js
  31. 3
      models/wekanCreator.js
  32. 3
      sandstorm.js
  33. 3
      server/authentication.js
  34. 3
      server/notifications/outgoing.js
  35. 4
      server/notifications/watch.js
  36. 3
      server/publications/boards.js
  37. 6
      server/publications/swimlanes.js

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
@ -145,7 +146,7 @@ BlazeComponent.extendComponent({
lastLabel() { lastLabel() {
const lastLabelId = this.currentData().activity.labelId; const lastLabelId = this.currentData().activity.labelId;
if (!lastLabelId) return null; if (!lastLabelId) return null;
const lastLabel = Boards.findOne( const lastLabel = ReactiveCache.getBoard(
this.currentData().activity.boardId, this.currentData().activity.boardId,
).getLabelById(lastLabelId); ).getLabelById(lastLabelId);
if (lastLabel && (lastLabel.name === undefined || lastLabel.name === '')) { if (lastLabel && (lastLabel.name === undefined || lastLabel.name === '')) {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
const subManager = new SubsManager(); const subManager = new SubsManager();
@ -223,8 +224,8 @@ BlazeComponent.extendComponent({
boardMembers(boardId) { boardMembers(boardId) {
let boardMembers = []; let boardMembers = [];
/* Bug Board icons random dance https://github.com/wekan/wekan/issues/4214 /* Bug Board icons random dance https://github.com/wekan/wekan/issues/4214
const lists = Boards.findOne({ '_id': boardId }) const lists = ReactiveCache.getBoard(boardId)
let members = lists.members; let members = lists.members
members.forEach(member => { members.forEach(member => {
boardMembers.push(member.userId); boardMembers.push(member.userId);
}); });
@ -266,14 +267,14 @@ BlazeComponent.extendComponent({
evt.preventDefault(); evt.preventDefault();
}, },
'click .js-clone-board'(evt) { 'click .js-clone-board'(evt) {
let title = getSlug(Boards.findOne(this.currentData()._id).title) || 'cloned-board'; let title = getSlug(ReactiveCache.getBoard(this.currentData()._id).title) || 'cloned-board';
Meteor.call( Meteor.call(
'copyBoard', 'copyBoard',
this.currentData()._id, this.currentData()._id,
{ {
sort: Boards.find({ archived: false }).count(), sort: Boards.find({ archived: false }).count(),
type: 'board', type: 'board',
title: Boards.findOne(this.currentData()._id).title, title: ReactiveCache.getBoard(this.currentData()._id).title,
}, },
(err, res) => { (err, res) => {
if (err) { if (err) {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales'; import moment from 'moment/min/moment-with-locales';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
import { DatePicker } from '/client/lib/datepicker'; import { DatePicker } from '/client/lib/datepicker';
@ -143,7 +144,7 @@ BlazeComponent.extendComponent({
const card = this.currentData(); const card = this.currentData();
let result = '#'; let result = '#';
if (card) { if (card) {
const board = Boards.findOne(card.boardId); const board = ReactiveCache.getBoard(card.boardId);
if (board) { if (board) {
result = FlowRouter.path('card', { result = FlowRouter.path('card', {
boardId: card.boardId, boardId: card.boardId,

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
import Cards from '/models/cards'; import Cards from '/models/cards';
import Boards from '/models/boards'; import Boards from '/models/boards';
@ -243,12 +244,12 @@ BlazeComponent.extendComponent({
}, },
swimlanes() { swimlanes() {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
return board.swimlanes(); return board.swimlanes();
}, },
aBoardLists() { aBoardLists() {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
return board.lists(); return board.lists();
}, },

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
addSubtask(event) { addSubtask(event) {
event.preventDefault(); event.preventDefault();
@ -6,7 +8,7 @@ BlazeComponent.extendComponent({
const cardId = this.currentData().cardId; const cardId = this.currentData().cardId;
const card = Cards.findOne(cardId); const card = Cards.findOne(cardId);
const sortIndex = -1; const sortIndex = -1;
const crtBoard = Boards.findOne(card.boardId); const crtBoard = ReactiveCache.getBoard(card.boardId);
const targetBoard = crtBoard.getDefaultSubtasksBoard(); const targetBoard = crtBoard.getDefaultSubtasksBoard();
const listId = targetBoard.getDefaultSubtasksListId(); const listId = targetBoard.getDefaultSubtasksListId();

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
import { Spinner } from '/client/lib/spinner'; import { Spinner } from '/client/lib/spinner';
@ -269,7 +270,7 @@ BlazeComponent.extendComponent({
const currentBoardId = Session.get('currentBoard'); const currentBoardId = Session.get('currentBoard');
arr = []; arr = [];
_.forEach( _.forEach(
Boards.findOne(currentBoardId) ReactiveCache.getBoard(currentBoardId)
.customFields() .customFields()
.fetch(), .fetch(),
function (field) { function (field) {
@ -288,8 +289,8 @@ BlazeComponent.extendComponent({
getLabels() { getLabels() {
const currentBoardId = Session.get('currentBoard'); const currentBoardId = Session.get('currentBoard');
if (Boards.findOne(currentBoardId).labels) { if (ReactiveCache.getBoard(currentBoardId).labels) {
return Boards.findOne(currentBoardId).labels.filter(label => { return ReactiveCache.getBoard(currentBoardId).labels.filter(label => {
return this.labels.get().indexOf(label._id) > -1; return this.labels.get().indexOf(label._id) > -1;
}); });
} }
@ -430,7 +431,7 @@ BlazeComponent.extendComponent({
this.boardId = Session.get('currentBoard'); this.boardId = Session.get('currentBoard');
// In order to get current board info // In order to get current board info
subManager.subscribe('board', this.boardId, false); subManager.subscribe('board', this.boardId, false);
this.board = Boards.findOne(this.boardId); this.board = ReactiveCache.getBoard(this.boardId);
// List where to insert card // List where to insert card
const list = $(Popup._getTopStack().openerElement).closest('.js-list'); const list = $(Popup._getTopStack().openerElement).closest('.js-list');
this.listId = Blaze.getData(list[0])._id; this.listId = Blaze.getData(list[0])._id;
@ -589,7 +590,6 @@ BlazeComponent.extendComponent({
this.isBoardTemplateSearch; this.isBoardTemplateSearch;
let board = {}; let board = {};
if (this.isTemplateSearch) { if (this.isTemplateSearch) {
//board = Boards.findOne((Meteor.user().profile || {}).templatesBoardId);
board._id = (Meteor.user().profile || {}).templatesBoardId; board._id = (Meteor.user().profile || {}).templatesBoardId;
} else { } else {
// Prefetch first non-current board id // Prefetch first non-current board id
@ -651,7 +651,7 @@ BlazeComponent.extendComponent({
if (!this.selectedBoardId) { if (!this.selectedBoardId) {
return []; return [];
} }
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
if (!this.isTemplateSearch || this.isCardTemplateSearch) { if (!this.isTemplateSearch || this.isCardTemplateSearch) {
return board.searchCards(this.term.get(), false); return board.searchCards(this.term.get(), false);
} else if (this.isListTemplateSearch) { } else if (this.isListTemplateSearch) {
@ -713,7 +713,7 @@ BlazeComponent.extendComponent({
element.type = 'list'; element.type = 'list';
_id = element.copy(this.boardId, this.swimlaneId); _id = element.copy(this.boardId, this.swimlaneId);
} else if (this.isSwimlaneTemplateSearch) { } else if (this.isSwimlaneTemplateSearch) {
element.sort = Boards.findOne(this.boardId) element.sort = ReactiveCache.getBoard(this.boardId)
.swimlanes() .swimlanes()
.count(); .count();
element.type = 'swimlane'; element.type = 'swimlane';

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import Attachments, { fileStoreStrategyFactory } from '/models/attachments'; import Attachments, { fileStoreStrategyFactory } from '/models/attachments';
const filesize = require('filesize'); const filesize = require('filesize');
@ -61,14 +62,14 @@ BlazeComponent.extendComponent({
return _version; return _version;
}); });
}); });
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
board.attachments = boardAttachments; board.attachments = boardAttachments;
return board; return board;
}) })
return ret; return ret;
}, },
getBoardData(boardid) { getBoardData(boardid) {
const ret = Boards.findOne(boardId); const ret = ReactiveCache.getBoard(boardId);
return ret; return ret;
}, },
events() { events() {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
Sidebar = null; Sidebar = null;
@ -284,7 +285,7 @@ Template.memberPopup.events({
Cards.find({ boardId, assignees: memberId }).forEach(card => { Cards.find({ boardId, assignees: memberId }).forEach(card => {
card.unassignAssignee(memberId); card.unassignAssignee(memberId);
}); });
Boards.findOne(boardId).removeMember(memberId); ReactiveCache.getBoard(boardId).removeMember(memberId);
Popup.back(); Popup.back();
}), }),
'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => { 'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => {

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
export class DialogWithBoardSwimlaneList extends BlazeComponent { export class DialogWithBoardSwimlaneList extends BlazeComponent {
/** returns the card dialog options /** returns the card dialog options
* @return Object with properties { boardId, swimlaneId, listId } * @return Object with properties { boardId, swimlaneId, listId }
@ -62,7 +64,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
/** sets the first swimlane id */ /** sets the first swimlane id */
setFirstSwimlaneId() { setFirstSwimlaneId() {
try { try {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
const swimlaneId = board.swimlanes().fetch()[0]._id; const swimlaneId = board.swimlanes().fetch()[0]._id;
this.selectedSwimlaneId.set(swimlaneId); this.selectedSwimlaneId.set(swimlaneId);
} catch (e) {} } catch (e) {}
@ -70,7 +72,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
/** sets the first list id */ /** sets the first list id */
setFirstListId() { setFirstListId() {
try { try {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
const listId = board.lists().fetch()[0]._id; const listId = board.lists().fetch()[0]._id;
this.selectedListId.set(listId); this.selectedListId.set(listId);
} catch (e) {} } catch (e) {}
@ -120,14 +122,14 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
/** returns all available swimlanes of the current board */ /** returns all available swimlanes of the current board */
swimlanes() { swimlanes() {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
const ret = board.swimlanes(); const ret = board.swimlanes();
return ret; return ret;
} }
/** returns all available lists of the current board */ /** returns all available lists of the current board */
lists() { lists() {
const board = Boards.findOne(this.selectedBoardId.get()); const board = ReactiveCache.getBoard(this.selectedBoardId.get());
const ret = board.lists(); const ret = board.lists();
return ret; return ret;
} }

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
// XXX There is no reason to define these shortcuts globally, they should be // XXX There is no reason to define these shortcuts globally, they should be
// attached to a template (most of them will go in the `board` template). // attached to a template (most of them will go in the `board` template).
@ -76,7 +78,7 @@ Mousetrap.bind(numbArray, (evt, key) => {
return; return;
} }
const currentBoardId = Session.get('currentBoard'); const currentBoardId = Session.get('currentBoard');
board = Boards.findOne(currentBoardId); board = ReactiveCache.getBoard(currentBoardId);
labels = board.labels; labels = board.labels;
if(MultiSelection.isActive()) if(MultiSelection.isActive())
{ {
@ -100,7 +102,7 @@ Mousetrap.bind(numArray, (evt, key) => {
if (currentUserId === null) { if (currentUserId === null) {
return; return;
} }
board = Boards.findOne(currentBoardId); board = ReactiveCache.getBoard(currentBoardId);
labels = board.labels; labels = board.labels;
if(MultiSelection.isActive() && Meteor.user().isBoardMember()) if(MultiSelection.isActive() && Meteor.user().isBoardMember())
{ {

@ -201,7 +201,7 @@ Utils = {
// XXX We should remove these two methods // XXX We should remove these two methods
goBoardId(_id) { goBoardId(_id) {
const board = Boards.findOne(_id); const board = ReactiveCache.getBoard(_id);
return ( return (
board && board &&
FlowRouter.go('board', { FlowRouter.go('board', {
@ -213,7 +213,7 @@ Utils = {
goCardId(_id) { goCardId(_id) {
const card = Cards.findOne(_id); const card = Cards.findOne(_id);
const board = Boards.findOne(card.boardId); const board = ReactiveCache.getBoard(card.boardId);
return ( return (
board && board &&
FlowRouter.go('card', { FlowRouter.go('card', {

@ -1,16 +1,17 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
Actions = new Mongo.Collection('actions'); Actions = new Mongo.Collection('actions');
Actions.allow({ Actions.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { 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 // 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 // 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 // we use with this collection. Moreover using a schema for this collection
@ -12,10 +14,10 @@ Activities = new Mongo.Collection('activities');
Activities.helpers({ Activities.helpers({
board() { board() {
return Boards.findOne(this.boardId); return ReactiveCache.getBoard(this.boardId);
}, },
oldBoard() { oldBoard() {
return Boards.findOne(this.oldBoardId); return ReactiveCache.getBoard(this.oldBoardId);
}, },
user() { user() {
return Users.findOne(this.userId); return Users.findOne(this.userId);
@ -108,7 +110,7 @@ if (Meteor.isServer) {
let participants = []; let participants = [];
let watchers = []; let watchers = [];
let title = 'act-activity-notify'; let title = 'act-activity-notify';
const board = Boards.findOne(activity.boardId); const board = ReactiveCache.getBoard(activity.boardId);
const description = `act-${activity.activityType}`; const description = `act-${activity.activityType}`;
const params = { const params = {
activityId: activity._id, activityId: activity._id,

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files'; import { FilesCollection } from 'meteor/ostrio:files';
import { isFileValid } from './fileValidation'; import { isFileValid } from './fileValidation';
@ -122,7 +123,7 @@ Attachments = new FilesCollection({
return false; return false;
} }
const board = Boards.findOne(fileObj.meta.boardId); const board = ReactiveCache.getBoard(fileObj.meta.boardId);
if (board.isPublic()) { if (board.isPublic()) {
return true; return true;
} }
@ -134,13 +135,13 @@ Attachments = new FilesCollection({
if (Meteor.isServer) { if (Meteor.isServer) {
Attachments.allow({ Attachments.allow({
insert(userId, fileObj) { insert(userId, fileObj) {
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
}, },
update(userId, fileObj) { update(userId, fileObj) {
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
}, },
remove(userId, fileObj) { remove(userId, fileObj) {
return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId));
}, },
fetch: ['meta'], fetch: ['meta'],
}); });

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
const storeName = 'attachments'; const storeName = 'attachments';
const defaultStoreOptions = { const defaultStoreOptions = {
beforeWrite: fileObj => { beforeWrite: fileObj => {
@ -35,19 +37,19 @@ if (Meteor.isServer) {
AttachmentsOld.allow({ AttachmentsOld.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
// We authorize the attachment download either: // We authorize the attachment download either:
// - if the board is public, everyone (even unconnected) can download it // - if the board is public, everyone (even unconnected) can download it
// - if the board is private, only board members can download it // - if the board is private, only board members can download it
download(userId, doc) { download(userId, doc) {
const board = Boards.findOne(doc.boardId); const board = ReactiveCache.getBoard(doc.boardId);
if (board.isPublic()) { if (board.isPublic()) {
return true; return true;
} else { } else {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import escapeForRegex from 'escape-string-regexp'; import escapeForRegex from 'escape-string-regexp';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
import { import {
@ -1124,7 +1125,7 @@ Boards.helpers({
}, },
getDefaultSubtasksBoard() { getDefaultSubtasksBoard() {
return Boards.findOne(this.getDefaultSubtasksBoardId()); return ReactiveCache.getBoard(this.getDefaultSubtasksBoardId());
}, },
//Date Settings option such as received date, start date and so on. //Date Settings option such as received date, start date and so on.
@ -1157,7 +1158,7 @@ Boards.helpers({
}, },
getDefaultDateSettingsBoard() { getDefaultDateSettingsBoard() {
return Boards.findOne(this.getDefaultDateSettingsBoardId()); return ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId());
}, },
getDefaultSubtasksListId() { getDefaultSubtasksListId() {
@ -1696,7 +1697,7 @@ if (Meteor.isServer) {
}, },
quitBoard(boardId) { quitBoard(boardId) {
check(boardId, String); check(boardId, String);
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
if (board) { if (board) {
const userId = Meteor.userId(); const userId = Meteor.userId();
const index = board.memberIndex(userId); const index = board.memberIndex(userId);
@ -1708,7 +1709,7 @@ if (Meteor.isServer) {
}, },
acceptInvite(boardId) { acceptInvite(boardId) {
check(boardId, String); check(boardId, String);
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
if (!board) { if (!board) {
throw new Meteor.Error('error-board-doesNotExist'); throw new Meteor.Error('error-board-doesNotExist');
} }
@ -1749,7 +1750,7 @@ if (Meteor.isServer) {
Meteor.methods({ Meteor.methods({
archiveBoard(boardId) { archiveBoard(boardId) {
check(boardId, String); check(boardId, String);
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
if (board) { if (board) {
const userId = Meteor.userId(); const userId = Meteor.userId();
const index = board.memberIndex(userId); const index = board.memberIndex(userId);

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
const commentReactionSchema = new SimpleSchema({ const commentReactionSchema = new SimpleSchema({
reactionCodepoint: { reactionCodepoint: {
type: String, type: String,
@ -49,13 +51,13 @@ CardCommentReactions.attachSchema(
CardCommentReactions.allow({ CardCommentReactions.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
fetch: ['boardId'], fetch: ['boardId'],
}); });

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import escapeForRegex from 'escape-string-regexp'; import escapeForRegex from 'escape-string-regexp';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
@ -74,13 +75,13 @@ CardComments.attachSchema(
CardComments.allow({ CardComments.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { 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) { 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'], fetch: ['userId', 'boardId'],
}); });

@ -490,19 +490,19 @@ Cards.attachSchema(
Cards.allow({ Cards.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc, fields) { update(userId, doc, fields) {
// Allow board members or logged in users if only vote get's changed // Allow board members or logged in users if only vote get's changed
return ( return (
allowIsBoardMember(userId, Boards.findOne(doc.boardId)) || allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)) ||
(_.isEqual(fields, ['vote', 'modifiedAt', 'dateLastActivity']) && (_.isEqual(fields, ['vote', 'modifiedAt', 'dateLastActivity']) &&
!!userId) !!userId)
); );
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId));
}, },
fetch: ['boardId'], fetch: ['boardId'],
}); });
@ -1093,7 +1093,7 @@ Cards.helpers({
if (card && card.description) return card.description; if (card && card.description) return card.description;
else return null; else return null;
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board && board.description) return board.description; if (board && board.description) return board.description;
else return null; else return null;
} else if (this.description) { } else if (this.description) {
@ -1112,7 +1112,7 @@ Cards.helpers({
return card.members; return card.members;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1134,7 +1134,7 @@ Cards.helpers({
return card.assignees; return card.assignees;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1150,7 +1150,7 @@ Cards.helpers({
assignMember(memberId) { assignMember(memberId) {
let ret; let ret;
if (this.isLinkedBoard()) { if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
ret = board.addMember(memberId); ret = board.addMember(memberId);
} else { } else {
ret = Cards.update( ret = Cards.update(
@ -1168,7 +1168,7 @@ Cards.helpers({
{ $addToSet: { assignees: assigneeId } }, { $addToSet: { assignees: assigneeId } },
); );
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
return board.addAssignee(assigneeId); return board.addAssignee(assigneeId);
} else { } else {
return Cards.update( return Cards.update(
@ -1185,7 +1185,7 @@ Cards.helpers({
{ $pull: { members: memberId } }, { $pull: { members: memberId } },
); );
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
return board.removeMember(memberId); return board.removeMember(memberId);
} else { } else {
return Cards.update({ _id: this._id }, { $pull: { members: memberId } }); return Cards.update({ _id: this._id }, { $pull: { members: memberId } });
@ -1199,7 +1199,7 @@ Cards.helpers({
{ $pull: { assignees: assigneeId } }, { $pull: { assignees: assigneeId } },
); );
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
return board.removeAssignee(assigneeId); return board.removeAssignee(assigneeId);
} else { } else {
return Cards.update( return Cards.update(
@ -1234,7 +1234,7 @@ Cards.helpers({
return card.receivedAt; return card.receivedAt;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1262,7 +1262,7 @@ Cards.helpers({
return card.startAt; return card.startAt;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1290,7 +1290,7 @@ Cards.helpers({
return card.dueAt; return card.dueAt;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1318,7 +1318,7 @@ Cards.helpers({
return card.endAt; return card.endAt;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1346,7 +1346,7 @@ Cards.helpers({
return card.isOvertime; return card.isOvertime;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1374,7 +1374,7 @@ Cards.helpers({
return card.spentTime; return card.spentTime;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1404,7 +1404,7 @@ Cards.helpers({
return null; return null;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else if (board && board.vote) { } else if (board && board.vote) {
@ -1430,7 +1430,7 @@ Cards.helpers({
return null; return null;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else if (board && board.vote) { } else if (board && board.vote) {
@ -1456,7 +1456,7 @@ Cards.helpers({
return null; return null;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else if (board && board.vote) { } else if (board && board.vote) {
@ -1516,7 +1516,7 @@ Cards.helpers({
return null; return null;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else if (board && board.poker) { } else if (board && board.poker) {
@ -1550,7 +1550,7 @@ Cards.helpers({
return null; return null;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else if (board && board.poker) { } else if (board && board.poker) {
@ -1699,7 +1699,7 @@ Cards.helpers({
return card.title; return card.title;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1722,21 +1722,21 @@ Cards.helpers({
if (card === undefined) { if (card === undefined) {
return null; return null;
} }
const board = Boards.findOne({ _id: card.boardId }); const board = ReactiveCache.getBoard(card.boardId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
return board.title; return board.title;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
return board.title; return board.title;
} }
} else { } else {
const board = Boards.findOne({ _id: this.boardId }); const board = ReactiveCache.getBoard(this.boardId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1762,7 +1762,7 @@ Cards.helpers({
return card.archived; return card.archived;
} }
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
const board = Boards.findOne({ _id: this.linkedId }); const board = ReactiveCache.getBoard(this.linkedId);
if (board === undefined) { if (board === undefined) {
return null; return null;
} else { } else {
@ -1967,7 +1967,7 @@ Cards.mutations({
// This should never happen, but there was a bug that was fixed in commit // This should never happen, but there was a bug that was fixed in commit
// ea0239538a68e225c867411a4f3e0d27c158383. // ea0239538a68e225c867411a4f3e0d27c158383.
if (!swimlaneId) { if (!swimlaneId) {
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
swimlaneId = board.getDefaultSwimline()._id; swimlaneId = board.getDefaultSwimline()._id;
} }
// Move the minicard to the end of the target list // 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 // This should never happen, but there was a bug that was fixed in commit
// ea0239538a68e225c867411a4f3e0d27c158383. // ea0239538a68e225c867411a4f3e0d27c158383.
if (!swimlaneId) { if (!swimlaneId) {
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
swimlaneId = board.getDefaultSwimline()._id; swimlaneId = board.getDefaultSwimline()._id;
} }
listId = listId || this.listId; listId = listId || this.listId;
@ -2016,7 +2016,7 @@ Cards.mutations({
// differs from the source board // differs from the source board
if (this.boardId !== boardId) { if (this.boardId !== boardId) {
// Get label names // Get label names
const oldBoard = Boards.findOne(this.boardId); const oldBoard = ReactiveCache.getBoard(this.boardId);
const oldBoardLabels = oldBoard.labels; const oldBoardLabels = oldBoard.labels;
const oldCardLabels = _.pluck( const oldCardLabels = _.pluck(
_.filter(oldBoardLabels, label => { _.filter(oldBoardLabels, label => {
@ -2025,7 +2025,7 @@ Cards.mutations({
'name', 'name',
); );
const newBoard = Boards.findOne(boardId); const newBoard = ReactiveCache.getBoard(boardId);
const newBoardLabels = newBoard.labels; const newBoardLabels = newBoard.labels;
const newCardLabelIds = _.pluck( const newCardLabelIds = _.pluck(
_.filter(newBoardLabels, label => { _.filter(newBoardLabels, label => {
@ -2683,10 +2683,10 @@ function cardMove(
Activities.insert({ Activities.insert({
userId, userId,
activityType: 'moveCardBoard', activityType: 'moveCardBoard',
boardName: Boards.findOne(doc.boardId).title, boardName: ReactiveCache.getBoard(doc.boardId).title,
boardId: doc.boardId, boardId: doc.boardId,
oldBoardId, oldBoardId,
oldBoardName: Boards.findOne(oldBoardId).title, oldBoardName: ReactiveCache.getBoard(oldBoardId).title,
cardId: doc._id, cardId: doc._id,
swimlaneName: Swimlanes.findOne(doc.swimlaneId).title, swimlaneName: Swimlanes.findOne(doc.swimlaneId).title,
swimlaneId: doc.swimlaneId, swimlaneId: doc.swimlaneId,
@ -3320,9 +3320,7 @@ if (Meteor.isServer) {
Authentication.checkLoggedIn(req.userId); Authentication.checkLoggedIn(req.userId);
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
// Check user has permission to add card to the board // Check user has permission to add card to the board
const board = Boards.findOne({ const board = ReactiveCache.getBoard(paramBoardId);
_id: paramBoardId,
});
const addPermission = allowIsBoardMemberCommentOnly(req.userId, board); const addPermission = allowIsBoardMemberCommentOnly(req.userId, board);
Authentication.checkAdminOrCondition(req.userId, addPermission); Authentication.checkAdminOrCondition(req.userId, addPermission);
const paramListId = req.params.listId; const paramListId = req.params.listId;

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { DataCache } from 'meteor-reactive-cache' import { DataCache } from 'meteor-reactive-cache'
Checklists = new Mongo.Collection('checklists'); Checklists = new Mongo.Collection('checklists');
@ -350,9 +351,7 @@ if (Meteor.isServer) {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
// Check user has permission to add checklist to the card // Check user has permission to add checklist to the card
const board = Boards.findOne({ const board = ReactiveCache.getBoard(paramBoardId);
_id: paramBoardId,
});
const addPermission = allowIsBoardMemberCommentOnly(req.userId, board); const addPermission = allowIsBoardMemberCommentOnly(req.userId, board);
Authentication.checkAdminOrCondition(req.userId, addPermission); Authentication.checkAdminOrCondition(req.userId, addPermission);
const paramCardId = req.params.cardId; const paramCardId = req.params.cardId;

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { isEmptyObject } from 'jquery'; import { isEmptyObject } from 'jquery';
import Boards from './boards'; import Boards from './boards';
@ -320,7 +321,7 @@ export class CsvCreator {
} }
// add the labels // add the labels
if (csvData[i][this.fieldIndex.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( for (const importedLabel of csvData[i][this.fieldIndex.labels].split(
' ', ' ',
)) { )) {
@ -387,7 +388,7 @@ export class CsvCreator {
Meteor.settings.public && Meteor.settings.public &&
Meteor.settings.public.sandstorm; Meteor.settings.public.sandstorm;
if (isSandstorm && currentBoardId) { if (isSandstorm && currentBoardId) {
const currentBoard = Boards.findOne(currentBoardId); const currentBoard = ReactiveCache.getBoard(currentBoardId);
currentBoard.archive(); currentBoard.archive();
} }
this.mapHeadertoCardFieldIndex(board[0]); this.mapHeadertoCardFieldIndex(board[0]);

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
CustomFields = new Mongo.Collection('customFields'); CustomFields = new Mongo.Collection('customFields');
/** /**
@ -363,7 +365,7 @@ if (Meteor.isServer) {
) { ) {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
const board = Boards.findOne({ _id: paramBoardId }); const board = ReactiveCache.getBoard(paramBoardId);
const id = CustomFields.direct.insert({ const id = CustomFields.direct.insert({
name: req.body.name, name: req.body.name,
type: req.body.type, type: req.body.type,

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales'; import moment from 'moment/min/moment-with-locales';
const Papa = require('papaparse'); const Papa = require('papaparse');
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
@ -34,7 +35,7 @@ export class Exporter {
}; };
_.extend( _.extend(
result, result,
Boards.findOne(this._boardId, { ReactiveCache.getBoard(this._boardId, {
fields: { fields: {
stars: 0, stars: 0,
}, },
@ -379,7 +380,7 @@ export class Exporter {
} }
canExport(user) { canExport(user) {
const board = Boards.findOne(this._boardId); const board = ReactiveCache.getBoard(this._boardId);
return board && board.isVisibleBy(user); return board && board.isVisibleBy(user);
} }
} }

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
Integrations = new Mongo.Collection('integrations'); Integrations = new Mongo.Collection('integrations');
/** /**
@ -102,7 +104,7 @@ const permissionHelper = {
allow(userId, doc) { allow(userId, doc) {
const user = Users.findOne(userId); const user = Users.findOne(userId);
const isAdmin = user && Meteor.user().isAdmin; const isAdmin = user && Meteor.user().isAdmin;
return isAdmin || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
}; };
Integrations.allow({ Integrations.allow({

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { ALLOWED_COLORS } from '/config/const'; import { ALLOWED_COLORS } from '/config/const';
Lists = new Mongo.Collection('lists'); Lists = new Mongo.Collection('lists');
@ -175,13 +176,13 @@ Lists.attachSchema(
Lists.allow({ Lists.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
fetch: ['boardId'], fetch: ['boardId'],
}); });
@ -269,7 +270,7 @@ Lists.helpers({
}, },
board() { board() {
return Boards.findOne(this.boardId); return ReactiveCache.getBoard(this.boardId);
}, },
getWipLimit(option) { getWipLimit(option) {
@ -559,7 +560,7 @@ if (Meteor.isServer) {
try { try {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
const board = Boards.findOne(paramBoardId); const board = ReactiveCache.getBoard(paramBoardId);
const id = Lists.insert({ const id = Lists.insert({
title: req.body.title, title: req.body.title,
boardId: paramBoardId, boardId: paramBoardId,

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
Rules = new Mongo.Collection('rules'); Rules = new Mongo.Collection('rules');
@ -63,7 +64,7 @@ Rules.helpers({
return Triggers.findOne({ _id: this.triggerId }); return Triggers.findOne({ _id: this.triggerId });
}, },
board() { board() {
return Boards.findOne({ _id: this.boardId }); return ReactiveCache.getBoard(this.boardId);
}, },
trigger() { trigger() {
return Triggers.findOne({ _id: this.triggerId }); return Triggers.findOne({ _id: this.triggerId });
@ -75,13 +76,13 @@ Rules.helpers({
Rules.allow({ Rules.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { 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'; import { ALLOWED_COLORS } from '/config/const';
Swimlanes = new Mongo.Collection('swimlanes'); Swimlanes = new Mongo.Collection('swimlanes');
@ -111,13 +112,13 @@ Swimlanes.attachSchema(
Swimlanes.allow({ Swimlanes.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId));
}, },
fetch: ['boardId'], fetch: ['boardId'],
}); });
@ -235,7 +236,7 @@ Swimlanes.helpers({
}, },
board() { board() {
return Boards.findOne(this.boardId); return ReactiveCache.getBoard(this.boardId);
}, },
colorClass() { colorClass() {
@ -469,7 +470,7 @@ if (Meteor.isServer) {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
const board = Boards.findOne(paramBoardId); const board = ReactiveCache.getBoard(paramBoardId);
const id = Swimlanes.insert({ const id = Swimlanes.insert({
title: req.body.title, title: req.body.title,
boardId: paramBoardId, boardId: paramBoardId,
@ -504,7 +505,7 @@ if (Meteor.isServer) {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
const paramSwimlaneId = req.params.swimlaneId; const paramSwimlaneId = req.params.swimlaneId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
const board = Boards.findOne(paramBoardId); const board = ReactiveCache.getBoard(paramBoardId);
const swimlane = Swimlanes.findOne({ const swimlane = Swimlanes.findOne({
_id: paramSwimlaneId, _id: paramSwimlaneId,
boardId: paramBoardId, boardId: paramBoardId,

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales'; import moment from 'moment/min/moment-with-locales';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
@ -753,7 +754,7 @@ export class TrelloCreator {
Meteor.settings.public && Meteor.settings.public &&
Meteor.settings.public.sandstorm; Meteor.settings.public.sandstorm;
if (isSandstorm && currentBoardId) { if (isSandstorm && currentBoardId) {
const currentBoard = Boards.findOne(currentBoardId); const currentBoard = ReactiveCache.getBoard(currentBoardId);
currentBoard.archive(); currentBoard.archive();
} }
this.parseActions(board.actions); this.parseActions(board.actions);

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
Triggers = new Mongo.Collection('triggers'); Triggers = new Mongo.Collection('triggers');
@ -24,13 +25,13 @@ Triggers.before.update((userId, doc, fieldNames, modifier) => {
Triggers.allow({ Triggers.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
}, },
remove(userId, doc) { 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) { isBoardAdmin(boardId) {
let board; let board;
if (boardId) { if (boardId) {
board = Boards.findOne(boardId); board = ReactiveCache.getBoard(boardId);
} else { } else {
board = Utils.getCurrentBoard(); board = Utils.getCurrentBoard();
} }
@ -1388,7 +1388,7 @@ if (Meteor.isServer) {
check(boardId, String); check(boardId, String);
const inviter = Meteor.user(); const inviter = Meteor.user();
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
const allowInvite = const allowInvite =
inviter && inviter &&
board && board &&
@ -1453,7 +1453,7 @@ if (Meteor.isServer) {
//Check if there is a subtasks board //Check if there is a subtasks board
if (board.subtasksDefaultBoardId) { 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 there is, also add user to that board
if (subBoard) { if (subBoard) {
subBoard.addMember(user._id); subBoard.addMember(user._id);
@ -1989,7 +1989,7 @@ if (Meteor.isServer) {
throw new Meteor.Error('error-invitation-code-not-exist'); throw new Meteor.Error('error-invitation-code-not-exist');
} else { } else {
invitationCode.boardsToBeInvited.forEach((boardId) => { invitationCode.boardsToBeInvited.forEach((boardId) => {
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
board.addMember(doc._id); board.addMember(doc._id);
}); });
if (!doc.profile) { if (!doc.profile) {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales'; import moment from 'moment/min/moment-with-locales';
const DateString = Match.Where(function(dateAsString) { const DateString = Match.Where(function(dateAsString) {
@ -907,7 +908,7 @@ export class WekanCreator {
Meteor.settings.public && Meteor.settings.public &&
Meteor.settings.public.sandstorm; Meteor.settings.public.sandstorm;
if (isSandstorm && currentBoardId) { if (isSandstorm && currentBoardId) {
const currentBoard = Boards.findOne(currentBoardId); const currentBoard = ReactiveCache.getBoard(currentBoardId);
currentBoard.archive(); currentBoard.archive();
} }
this.parseActivities(board); this.parseActivities(board);

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { Picker } from 'meteor/communitypackages:picker'; import { Picker } from 'meteor/communitypackages:picker';
@ -215,7 +216,7 @@ if (isSandstorm && Meteor.isServer) {
const comment = CardComments.findOne(doc.commentId); const comment = CardComments.findOne(doc.commentId);
caption = { defaultText: comment.text }; caption = { defaultText: comment.text };
const activeMembers = _.pluck( const activeMembers = _.pluck(
Boards.findOne(sandstormBoard._id).activeMembers(), ReactiveCache.getBoard(sandstormBoard._id).activeMembers(),
'userId', 'userId',
); );
(comment.text.match(/\B@([\w.]*)/g) || []).forEach(username => { (comment.text.match(/\B@([\w.]*)/g) || []).forEach(username => {

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import Fiber from 'fibers'; import Fiber from 'fibers';
Meteor.startup(() => { Meteor.startup(() => {
@ -55,7 +56,7 @@ Meteor.startup(() => {
Authentication.checkBoardAccess = function(userId, boardId) { Authentication.checkBoardAccess = function(userId, boardId) {
Authentication.checkLoggedIn(userId); Authentication.checkLoggedIn(userId);
const board = Boards.findOne({ _id: boardId }); const board = ReactiveCache.getBoard(boardId);
const normalAccess = const normalAccess =
board.permission === 'public' || board.permission === 'public' ||
board.members.some(e => e.userId === userId && e.isActive); board.members.some(e => e.userId === userId && e.isActive);

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
if (Meteor.isServer) { if (Meteor.isServer) {
@ -79,7 +80,7 @@ if (Meteor.isServer) {
cardId: paramCardId, cardId: paramCardId,
boardId: paramBoardId, boardId: paramBoardId,
}); });
const board = Boards.findOne(paramBoardId); const board = ReactiveCache.getBoard(paramBoardId);
const card = Cards.findOne(paramCardId); const card = Cards.findOne(paramCardId);
if (board && card) { if (board && card) {
if (comment) { if (comment) {

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
Meteor.methods({ Meteor.methods({
watch(watchableType, id, level) { watch(watchableType, id, level) {
check(watchableType, String); check(watchableType, String);
@ -9,7 +11,7 @@ Meteor.methods({
let watchableObj = null; let watchableObj = null;
let board = null; let board = null;
if (watchableType === 'board') { if (watchableType === 'board') {
watchableObj = Boards.findOne(id); watchableObj = ReactiveCache.getBoard(id);
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist'); if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
board = watchableObj; board = watchableObj;
} else if (watchableType === 'list') { } else if (watchableType === 'list') {

@ -2,6 +2,7 @@
// non-archived boards: // non-archived boards:
// 1. that the user is a member of // 1. that the user is a member of
// 2. the user has starred // 2. the user has starred
import { ReactiveCache } from '/imports/reactiveCache';
import Users from "../../models/users"; import Users from "../../models/users";
import Org from "../../models/org"; import Org from "../../models/org";
import Team from "../../models/team"; import Team from "../../models/team";
@ -326,7 +327,7 @@ Meteor.methods({
check(boardId, String); check(boardId, String);
check(properties, Object); check(properties, Object);
const board = Boards.findOne(boardId); const board = ReactiveCache.getBoard(boardId);
if (board) { if (board) {
for (const key in properties) { for (const key in properties) {
board[key] = properties[key]; board[key] = properties[key];

@ -1,10 +1,12 @@
import { ReactiveCache } from '/imports/reactiveCache';
Meteor.methods({ Meteor.methods({
copySwimlane(swimlaneId, toBoardId) { copySwimlane(swimlaneId, toBoardId) {
check(swimlaneId, String); check(swimlaneId, String);
check(toBoardId, String); check(toBoardId, String);
const swimlane = Swimlanes.findOne(swimlaneId); const swimlane = Swimlanes.findOne(swimlaneId);
const toBoard = Boards.findOne(toBoardId); const toBoard = ReactiveCache.getBoard(toBoardId);
if (swimlane && toBoard) { if (swimlane && toBoard) {
swimlane.copy(toBoardId); swimlane.copy(toBoardId);
@ -19,7 +21,7 @@ Meteor.methods({
check(toBoardId, String); check(toBoardId, String);
const swimlane = Swimlanes.findOne(swimlaneId); const swimlane = Swimlanes.findOne(swimlaneId);
const toBoard = Boards.findOne(toBoardId); const toBoard = ReactiveCache.getBoard(toBoardId);
if (swimlane && toBoard) { if (swimlane && toBoard) {
swimlane.move(toBoardId); swimlane.move(toBoardId);

Loading…
Cancel
Save