mirror of
https://github.com/wekan/wekan.git
synced 2025-06-27 17:00:47 -04:00
Move every Users.findOne() to the ReactiveCache
This commit is contained in:
parent
bf48d4371c
commit
6e1ef3d94a
35 changed files with 175 additions and 125 deletions
|
@ -166,14 +166,7 @@ BlazeComponent.extendComponent({
|
|||
if (allowPrivateVisibilityOnly !== undefined && allowPrivateVisibilityOnly.booleanValue) {
|
||||
query.$and.push({ 'permission': 'private' });
|
||||
}
|
||||
const currUser = Users.findOne(Meteor.userId());
|
||||
|
||||
// const currUser = Users.findOne(Meteor.userId(), {
|
||||
// fields: {
|
||||
// orgs: 1,
|
||||
// teams: 1,
|
||||
// },
|
||||
// });
|
||||
const currUser = ReactiveCache.getCurrentUser();
|
||||
|
||||
let orgIdsUserBelongs = currUser !== undefined && currUser.teams !== 'undefined' ? currUser.orgIdsUserBelongs() : '';
|
||||
if (orgIdsUserBelongs && orgIdsUserBelongs != '') {
|
||||
|
|
|
@ -775,7 +775,7 @@ const filterMembers = (filterTerm) => {
|
|||
members = members
|
||||
.map(member => ({
|
||||
member,
|
||||
user: Users.findOne(member.userId)
|
||||
user: ReactiveCache.getUser(member.userId)
|
||||
}))
|
||||
.filter(({ user }) =>
|
||||
(user.profile.fullname !== undefined && user.profile.fullname.toLowerCase().indexOf(filterTerm.toLowerCase()) !== -1)
|
||||
|
@ -1640,7 +1640,7 @@ Template.cardAssigneesPopup.helpers({
|
|||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1655,13 +1655,13 @@ Template.cardAssigneePopup.helpers({
|
|||
},
|
||||
|
||||
memberType() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
return user && user.isBoardAdmin() ? 'admin' : 'normal';
|
||||
},
|
||||
|
||||
/*
|
||||
presenceStatusClassName() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
const userPresence = presences.findOne({ userId: this.userId });
|
||||
if (user && user.isInvitedTo(Session.get('currentBoard'))) return 'pending';
|
||||
else if (!userPresence) return 'disconnected';
|
||||
|
@ -1678,7 +1678,7 @@ Template.cardAssigneePopup.helpers({
|
|||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ BlazeComponent.extendComponent({
|
|||
const currentBoard = Utils.getCurrentBoard();
|
||||
callback(
|
||||
$.map(currentBoard.activeMembers(), member => {
|
||||
const user = Users.findOne(member.userId);
|
||||
const user = ReactiveCache.getUser(member.userId);
|
||||
return user.username.indexOf(term) === 0 ? user : null;
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
const specialHandles = [
|
||||
{userId: 'board_members', username: 'board_members'},
|
||||
{userId: 'card_members', username: 'card_members'}
|
||||
|
@ -19,7 +21,7 @@ BlazeComponent.extendComponent({
|
|||
currentBoard
|
||||
.activeMembers()
|
||||
.map(member => {
|
||||
const user = Users.findOne(member.userId);
|
||||
const user = ReactiveCache.getUser(member.userId);
|
||||
const username = user.username;
|
||||
const fullName = user.profile && user.profile !== undefined && user.profile.fullname ? user.profile.fullname : "";
|
||||
return username.includes(term) || fullName.includes(term) ? user : null;
|
||||
|
@ -334,7 +336,7 @@ Blaze.Template.registerHelper(
|
|||
DOMPurify.sanitize(content, { ALLOW_UNKNOWN_PROTOCOLS: true }),
|
||||
);
|
||||
const knowedUsers = _.union(currentBoard.members.map(member => {
|
||||
const u = Users.findOne(member.userId);
|
||||
const u = ReactiveCache.getUser(member.userId);
|
||||
if (u) {
|
||||
member.username = u.username;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
// this hides the notifications drawer if anyone clicks off of the panel
|
||||
Template.body.events({
|
||||
click(event) {
|
||||
|
@ -12,7 +14,7 @@ Template.body.events({
|
|||
|
||||
Template.notifications.helpers({
|
||||
unreadNotifications() {
|
||||
const notifications = Users.findOne(Meteor.userId()).notifications();
|
||||
const notifications = ReactiveCache.getCurrentUser().notifications();
|
||||
const unreadNotifications = _.filter(notifications, v => !v.read);
|
||||
return unreadNotifications.length;
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { toggleNotificationsDrawer } from './notifications.js';
|
||||
|
||||
Template.notificationsDrawer.onCreated(function() {
|
||||
|
@ -14,7 +15,7 @@ Template.notificationsDrawer.onCreated(function() {
|
|||
|
||||
Template.notificationsDrawer.helpers({
|
||||
transformedProfile() {
|
||||
return Users.findOne(Meteor.userId());
|
||||
return ReactiveCache.getCurrentUser();
|
||||
},
|
||||
readNotifications() {
|
||||
const readNotifications = _.filter(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
import { AttachmentStorage } from '/models/attachments';
|
||||
import { CardSearchPagedComponent } from '/client/lib/cardSearch';
|
||||
|
@ -163,7 +164,7 @@ class AdminReport extends BlazeComponent {
|
|||
userNames(members) {
|
||||
let text = '';
|
||||
members.forEach(member => {
|
||||
const user = Users.findOne(member.userId);
|
||||
const user = ReactiveCache.getUser(member.userId);
|
||||
text += text ? ', ' : '';
|
||||
if (user) {
|
||||
text += user.username;
|
||||
|
@ -181,7 +182,7 @@ class AdminReport extends BlazeComponent {
|
|||
userNames(userIds) {
|
||||
let text = '';
|
||||
userIds.forEach(userId => {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
text += text ? ', ' : '';
|
||||
text += user.username;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
const orgsPerPage = 25;
|
||||
const teamsPerPage = 25;
|
||||
const usersPerPage = 25;
|
||||
|
@ -202,7 +204,7 @@ Template.teamRow.helpers({
|
|||
|
||||
Template.peopleRow.helpers({
|
||||
userData() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -245,7 +247,7 @@ Template.editTeamPopup.helpers({
|
|||
|
||||
Template.editUserPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
authentications() {
|
||||
return Template.instance().authenticationMethods.get();
|
||||
|
@ -258,12 +260,12 @@ Template.editUserPopup.helpers({
|
|||
},
|
||||
isSelected(match) {
|
||||
const userId = Template.instance().data.userId;
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === match;
|
||||
},
|
||||
isLdap() {
|
||||
const userId = Template.instance().data.userId;
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === 'ldap';
|
||||
},
|
||||
errorMessage() {
|
||||
|
@ -318,7 +320,7 @@ Template.newTeamPopup.helpers({
|
|||
|
||||
Template.newUserPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
authentications() {
|
||||
return Template.instance().authenticationMethods.get();
|
||||
|
@ -332,7 +334,7 @@ Template.newUserPopup.helpers({
|
|||
isSelected(match) {
|
||||
const userId = Template.instance().data.userId;
|
||||
if(userId){
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === match;
|
||||
}
|
||||
else{
|
||||
|
@ -341,7 +343,7 @@ Template.newUserPopup.helpers({
|
|||
},
|
||||
isLdap() {
|
||||
const userId = Template.instance().data.userId;
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === 'ldap';
|
||||
},
|
||||
errorMessage() {
|
||||
|
@ -382,7 +384,7 @@ BlazeComponent.extendComponent({
|
|||
BlazeComponent.extendComponent({
|
||||
onCreated() {},
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
events() {
|
||||
return [
|
||||
|
@ -440,7 +442,7 @@ BlazeComponent.extendComponent({
|
|||
|
||||
if(document.getElementById('addAction').checked){
|
||||
for(let i = 0; i < selectedUserChkBoxUserIds.length; i++){
|
||||
currentUser = Users.findOne(selectedUserChkBoxUserIds[i]);
|
||||
currentUser = ReactiveCache.getUser(selectedUserChkBoxUserIds[i]);
|
||||
userTms = currentUser.teams;
|
||||
if(userTms == undefined || userTms.length == 0){
|
||||
userTms = [];
|
||||
|
@ -469,7 +471,7 @@ BlazeComponent.extendComponent({
|
|||
}
|
||||
else{
|
||||
for(let i = 0; i < selectedUserChkBoxUserIds.length; i++){
|
||||
currentUser = Users.findOne(selectedUserChkBoxUserIds[i]);
|
||||
currentUser = ReactiveCache.getUser(selectedUserChkBoxUserIds[i]);
|
||||
userTms = currentUser.teams;
|
||||
if(userTms !== undefined || userTms.length > 0)
|
||||
{
|
||||
|
@ -647,7 +649,7 @@ Template.editTeamPopup.events({
|
|||
Template.editUserPopup.events({
|
||||
submit(event, templateInstance) {
|
||||
event.preventDefault();
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
const username = templateInstance.find('.js-profile-username').value.trim();
|
||||
const fullname = templateInstance.find('.js-profile-fullname').value.trim();
|
||||
const initials = templateInstance.find('.js-profile-initials').value.trim();
|
||||
|
@ -1139,19 +1141,19 @@ Template.settingsUserPopup.events({
|
|||
|
||||
Template.settingsUserPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
authentications() {
|
||||
return Template.instance().authenticationMethods.get();
|
||||
},
|
||||
isSelected(match) {
|
||||
const userId = Template.instance().data.userId;
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === match;
|
||||
},
|
||||
isLdap() {
|
||||
const userId = Template.instance().data.userId;
|
||||
const selected = Users.findOne(userId).authenticationMethod;
|
||||
const selected = ReactiveCache.getUser(userId).authenticationMethod;
|
||||
return selected === 'ldap';
|
||||
},
|
||||
errorMessage() {
|
||||
|
|
|
@ -170,13 +170,13 @@ EscapeActions.register(
|
|||
|
||||
Template.memberPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
isBoardAdmin() {
|
||||
return Meteor.user().isBoardAdmin();
|
||||
},
|
||||
memberType() {
|
||||
const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
|
||||
const type = ReactiveCache.getUser(this.userId).isBoardAdmin() ? 'admin' : 'normal';
|
||||
if (type === 'normal') {
|
||||
const currentBoard = Utils.getCurrentBoard();
|
||||
const commentOnly = currentBoard.hasCommentOnly(this.userId);
|
||||
|
@ -196,7 +196,7 @@ Template.memberPopup.helpers({
|
|||
}
|
||||
},
|
||||
isInvited() {
|
||||
return Users.findOne(this.userId).isInvitedTo(Session.get('currentBoard'));
|
||||
return ReactiveCache.getUser(this.userId).isInvitedTo(Session.get('currentBoard'));
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -299,7 +299,7 @@ Template.memberPopup.events({
|
|||
|
||||
Template.removeMemberPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
board() {
|
||||
return Utils.getCurrentBoard();
|
||||
|
@ -1450,7 +1450,7 @@ BlazeComponent.extendComponent({
|
|||
|
||||
isBoardMember() {
|
||||
const userId = this.currentData().__originalId;
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
return user && user.isBoardMember();
|
||||
},
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ Template.userAvatar.helpers({
|
|||
},
|
||||
|
||||
memberType() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
return user && user.isBoardAdmin() ? 'admin' : 'normal';
|
||||
},
|
||||
|
||||
/*
|
||||
presenceStatusClassName() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
const userPresence = presences.findOne({ userId: this.userId });
|
||||
if (user && user.isInvitedTo(Session.get('currentBoard'))) return 'pending';
|
||||
else if (!userPresence) return 'disconnected';
|
||||
|
@ -36,12 +36,12 @@ Template.userAvatar.helpers({
|
|||
|
||||
Template.userAvatarInitials.helpers({
|
||||
initials() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
return user && user.getInitials();
|
||||
},
|
||||
|
||||
viewPortWidth() {
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getUser(this.userId);
|
||||
return ((user && user.getInitials().length) || 1) * 12;
|
||||
},
|
||||
});
|
||||
|
@ -249,7 +249,7 @@ Template.cardMembersPopup.helpers({
|
|||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -264,7 +264,7 @@ Template.cardMembersPopup.events({
|
|||
|
||||
Template.cardMemberPopup.helpers({
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { Session } from 'meteor/session';
|
||||
import moment from 'moment/min/moment-with-locales';
|
||||
|
@ -22,7 +23,7 @@ Blaze.registerHelper('currentSetting', () => {
|
|||
return ret;
|
||||
});
|
||||
|
||||
Blaze.registerHelper('getUser', userId => Users.findOne(userId));
|
||||
Blaze.registerHelper('getUser', userId => ReactiveCache.getUser(userId));
|
||||
|
||||
Blaze.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
||||
|
||||
|
|
|
@ -31,10 +31,18 @@ ReactiveCacheServer = {
|
|||
const ret = CustomFields.find(selector).fetch();
|
||||
return ret;
|
||||
},
|
||||
getUser(id) {
|
||||
const ret = Users.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
const ret = Settings.findOne();
|
||||
return ret;
|
||||
},
|
||||
getCurrentUser() {
|
||||
const ret = Meteor.user();
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
// only the Client is reactive
|
||||
|
@ -111,6 +119,16 @@ ReactiveCacheClient = {
|
|||
const ret = this.__customFields.get(Jsons.stringify(selector));
|
||||
return ret;
|
||||
},
|
||||
getUser(id) {
|
||||
if (!this.__user) {
|
||||
this.__user = new DataCache(userId => {
|
||||
const _ret = Users.findOne(userId);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__user.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||
this.__currentSetting = new DataCache(() => {
|
||||
|
@ -120,6 +138,16 @@ ReactiveCacheClient = {
|
|||
}
|
||||
const ret = this.__currentSetting.get();
|
||||
return ret;
|
||||
},
|
||||
getCurrentUser() {
|
||||
if (!this.__currentUser || !this.__currentUser.get()) {
|
||||
this.__currentUser = new DataCache(() => {
|
||||
const _ret = Meteor.user();
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__currentUser.get();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,6 +221,15 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getUser(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getUser(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getUser(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
@ -202,6 +239,15 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentUser() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getCurrentUser();
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getCurrentUser();
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
export { ReactiveCache };
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
AccountSettings = new Mongo.Collection('accountSettings');
|
||||
|
||||
AccountSettings.attachSchema(
|
||||
|
@ -44,7 +46,7 @@ AccountSettings.attachSchema(
|
|||
|
||||
AccountSettings.allow({
|
||||
update(userId) {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
return user && user.isAdmin;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -20,10 +20,10 @@ Activities.helpers({
|
|||
return ReactiveCache.getBoard(this.oldBoardId);
|
||||
},
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
member() {
|
||||
return Users.findOne(this.memberId);
|
||||
return ReactiveCache.getUser(this.memberId);
|
||||
},
|
||||
list() {
|
||||
return ReactiveCache.getList(this.listId);
|
||||
|
@ -203,7 +203,7 @@ if (Meteor.isServer) {
|
|||
if (board) {
|
||||
const comment = params.comment;
|
||||
const knownUsers = board.members.map(member => {
|
||||
const u = Users.findOne(member.userId);
|
||||
const u = ReactiveCache.getUser(member.userId);
|
||||
if (u) {
|
||||
member.username = u.username;
|
||||
member.emails = u.emails;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Announcements = new Mongo.Collection('announcements');
|
||||
|
||||
Announcements.attachSchema(
|
||||
|
@ -49,7 +51,7 @@ Announcements.attachSchema(
|
|||
|
||||
Announcements.allow({
|
||||
update(userId) {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
return user && user.isAdmin;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { FilesCollection } from 'meteor/ostrio:files';
|
||||
import { formatFleURL } from 'meteor/ostrio:files/lib';
|
||||
|
@ -100,7 +101,7 @@ Avatars = new FilesCollection({
|
|||
const isValid = Promise.await(isFileValid(fileObj, avatarsUploadMimeTypes, avatarsUploadSize, avatarsUploadExternalProgram));
|
||||
|
||||
if (isValid) {
|
||||
Users.findOne(fileObj.userId).setAvatarUrl(`${formatFleURL(fileObj)}?auth=false&brokenIsFine=true`);
|
||||
ReactiveCache.getUser(fileObj.userId).setAvatarUrl(`${formatFleURL(fileObj)}?auth=false&brokenIsFine=true`);
|
||||
} else {
|
||||
Avatars.remove(fileObj._id);
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ Avatars = new FilesCollection({
|
|||
onBeforeRemove(files) {
|
||||
files.forEach(fileObj => {
|
||||
if (fileObj.userId) {
|
||||
Users.findOne(fileObj.userId).setAvatarUrl('');
|
||||
ReactiveCache.getUser(fileObj.userId).setAvatarUrl('');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1597,7 +1597,7 @@ Boards.userBoards = (
|
|||
selector = {},
|
||||
projection = {},
|
||||
) => {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ CardComments.helpers({
|
|||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
|
||||
reactions() {
|
||||
|
|
|
@ -754,7 +754,7 @@ Cards.helpers({
|
|||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
return ReactiveCache.getUser(this.userId);
|
||||
},
|
||||
|
||||
isAssigned(memberId) {
|
||||
|
@ -2744,7 +2744,7 @@ function cardMembers(userId, doc, fieldNames, modifier) {
|
|||
// Say hello to the new member
|
||||
if (modifier.$addToSet && modifier.$addToSet.members) {
|
||||
memberId = modifier.$addToSet.members;
|
||||
const username = Users.findOne(memberId).username;
|
||||
const username = ReactiveCache.getUser(memberId).username;
|
||||
if (!_.contains(doc.members, memberId)) {
|
||||
Activities.insert({
|
||||
userId,
|
||||
|
@ -2762,7 +2762,7 @@ function cardMembers(userId, doc, fieldNames, modifier) {
|
|||
// Say goodbye to the former member
|
||||
if (modifier.$pull && modifier.$pull.members) {
|
||||
memberId = modifier.$pull.members;
|
||||
const username = Users.findOne(memberId).username;
|
||||
const username = ReactiveCache.getUser(memberId).username;
|
||||
// Check that the former member is member of the card
|
||||
if (_.contains(doc.members, memberId)) {
|
||||
Activities.insert({
|
||||
|
@ -2785,7 +2785,7 @@ function cardAssignees(userId, doc, fieldNames, modifier) {
|
|||
// Say hello to the new assignee
|
||||
if (modifier.$addToSet && modifier.$addToSet.assignees) {
|
||||
assigneeId = modifier.$addToSet.assignees;
|
||||
const username = Users.findOne(assigneeId).username;
|
||||
const username = ReactiveCache.getUser(assigneeId).username;
|
||||
if (!_.contains(doc.assignees, assigneeId)) {
|
||||
Activities.insert({
|
||||
userId,
|
||||
|
@ -2802,7 +2802,7 @@ function cardAssignees(userId, doc, fieldNames, modifier) {
|
|||
// Say goodbye to the former assignee
|
||||
if (modifier.$pull && modifier.$pull.assignees) {
|
||||
assigneeId = modifier.$pull.assignees;
|
||||
const username = Users.findOne(assigneeId).username;
|
||||
const username = ReactiveCache.getUser(assigneeId).username;
|
||||
// Check that the former assignee is assignee of the card
|
||||
if (_.contains(doc.assignees, assigneeId)) {
|
||||
Activities.insert({
|
||||
|
@ -2967,7 +2967,7 @@ const findDueCards = days => {
|
|||
archived: false,
|
||||
dueAt: { $gte: $from, $lt: $to },
|
||||
}).forEach(card => {
|
||||
const username = Users.findOne(card.userId).username;
|
||||
const username = ReactiveCache.getUser(card.userId).username;
|
||||
const activity = {
|
||||
userId: card.userId,
|
||||
username,
|
||||
|
@ -3162,7 +3162,7 @@ if (Meteor.isServer) {
|
|||
},
|
||||
);
|
||||
}
|
||||
const username = Users.findOne(userId).username;
|
||||
const username = ReactiveCache.getUser(userId).username;
|
||||
const activity = {
|
||||
userId,
|
||||
username,
|
||||
|
@ -3343,9 +3343,7 @@ if (Meteor.isServer) {
|
|||
},
|
||||
{ sort: ['sort'] },
|
||||
);
|
||||
const check = Users.findOne({
|
||||
_id: req.body.authorId,
|
||||
});
|
||||
const check = ReactiveCache.getUser(req.body.authorId);
|
||||
const members = req.body.members;
|
||||
const assignees = req.body.assignees;
|
||||
if (typeof check !== 'undefined') {
|
||||
|
|
|
@ -102,7 +102,7 @@ Integrations.Const = {
|
|||
};
|
||||
const permissionHelper = {
|
||||
allow(userId, doc) {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
const isAdmin = user && Meteor.user().isAdmin;
|
||||
return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
|
||||
},
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
InvitationCodes = new Mongo.Collection('invitation_codes');
|
||||
|
||||
InvitationCodes.attachSchema(
|
||||
|
@ -54,7 +56,7 @@ InvitationCodes.attachSchema(
|
|||
|
||||
InvitationCodes.helpers({
|
||||
author() {
|
||||
return Users.findOne(this.authorId);
|
||||
return ReactiveCache.getUser(this.authorId);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Org = new Mongo.Collection('org');
|
||||
|
||||
/**
|
||||
|
@ -78,10 +80,8 @@ Org.attachSchema(
|
|||
if (Meteor.isServer) {
|
||||
Org.allow({
|
||||
insert(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
@ -89,10 +89,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
update(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
@ -100,10 +98,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
remove(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
|
|
@ -160,7 +160,7 @@ Settings.helpers({
|
|||
});
|
||||
Settings.allow({
|
||||
update(userId) {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
return user && user.isAdmin;
|
||||
},
|
||||
});
|
||||
|
@ -250,16 +250,13 @@ if (Meteor.isServer) {
|
|||
|
||||
function sendInvitationEmail(_id) {
|
||||
const icode = InvitationCodes.findOne(_id);
|
||||
const author = Users.findOne(Meteor.userId());
|
||||
const author = ReactiveCache.getCurrentUser();
|
||||
try {
|
||||
const fullName = Users.findOne(icode.authorId)
|
||||
&& Users.findOne(icode.authorId).profile
|
||||
&& Users.findOne(icode.authorId).profile !== undefined
|
||||
&& Users.findOne(icode.authorId).profile.fullname ? Users.findOne(icode.authorId).profile.fullname : "";
|
||||
const fullName = ReactiveCache.getUser(icode.authorId)?.profile?.fullname || "";
|
||||
|
||||
const params = {
|
||||
email: icode.email,
|
||||
inviter: fullName != "" ? fullName + " (" + Users.findOne(icode.authorId).username + " )" : Users.findOne(icode.authorId).username,
|
||||
inviter: fullName != "" ? fullName + " (" + ReactiveCache.getUser(icode.authorId).username + " )" : ReactiveCache.getUser(icode.authorId).username,
|
||||
user: icode.email.split('@')[0],
|
||||
icode: icode.code,
|
||||
url: FlowRouter.url('sign-up'),
|
||||
|
@ -344,7 +341,7 @@ if (Meteor.isServer) {
|
|||
check(emails, [String]);
|
||||
check(boards, [String]);
|
||||
|
||||
const user = Users.findOne(Meteor.userId());
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user.isAdmin && !isNonAdminAllowedToSendMail(user)) {
|
||||
rc = -1;
|
||||
throw new Meteor.Error('not-allowed');
|
||||
|
|
|
@ -253,17 +253,17 @@ Swimlanes.helpers({
|
|||
},
|
||||
|
||||
isListTemplatesSwimlane() {
|
||||
const user = Users.findOne(Meteor.userId());
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
return (user.profile || {}).listTemplatesSwimlaneId === this._id;
|
||||
},
|
||||
|
||||
isCardTemplatesSwimlane() {
|
||||
const user = Users.findOne(Meteor.userId());
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
return (user.profile || {}).cardTemplatesSwimlaneId === this._id;
|
||||
},
|
||||
|
||||
isBoardTemplatesSwimlane() {
|
||||
const user = Users.findOne(Meteor.userId());
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
return (user.profile || {}).boardTemplatesSwimlaneId === this._id;
|
||||
},
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
TableVisibilityModeSettings = new Mongo.Collection('tableVisibilityModeSettings');
|
||||
|
||||
TableVisibilityModeSettings.attachSchema(
|
||||
|
@ -44,7 +46,7 @@ TableVisibilityModeSettings.attachSchema(
|
|||
|
||||
TableVisibilityModeSettings.allow({
|
||||
update(userId) {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
return user && user.isAdmin;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Team = new Mongo.Collection('team');
|
||||
|
||||
/**
|
||||
|
@ -77,10 +79,8 @@ Team.attachSchema(
|
|||
if (Meteor.isServer) {
|
||||
Team.allow({
|
||||
insert(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
@ -88,10 +88,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
update(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
@ -99,10 +97,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
remove(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
|
|
@ -503,9 +503,7 @@ Users.attachSchema(
|
|||
|
||||
Users.allow({
|
||||
update(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
return true;
|
||||
if (!user) {
|
||||
|
@ -1445,7 +1443,7 @@ if (Meteor.isServer) {
|
|||
});
|
||||
}
|
||||
Accounts.sendEnrollmentEmail(newUserId);
|
||||
user = Users.findOne(newUserId);
|
||||
user = ReactiveCache.getUser(newUserId);
|
||||
}
|
||||
|
||||
board.addMember(user._id);
|
||||
|
@ -1949,9 +1947,7 @@ if (Meteor.isServer) {
|
|||
|
||||
Users.after.insert((userId, doc) => {
|
||||
// HACK
|
||||
doc = Users.findOne({
|
||||
_id: doc._id,
|
||||
});
|
||||
doc = ReactiveCache.getUser(doc._id);
|
||||
if (doc.createdThroughApi) {
|
||||
// The admin user should be able to create a user despite disabling registration because
|
||||
// it is two different things (registration and creation).
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
//var nodemailer = require('nodemailer');
|
||||
|
||||
|
@ -30,7 +31,7 @@ Meteor.startup(() => {
|
|||
// so we pass userId with closure
|
||||
const userId = user._id;
|
||||
Meteor.setTimeout(() => {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
|
||||
// for each user, in the timed period, only the first call will get the cached content,
|
||||
// other calls will get nothing
|
||||
|
|
|
@ -22,7 +22,7 @@ Notifications = {
|
|||
getUsers: watchers => {
|
||||
const users = [];
|
||||
watchers.forEach(userId => {
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
if (user) users.push(user);
|
||||
});
|
||||
return users;
|
||||
|
|
|
@ -134,7 +134,7 @@ if (Meteor.isServer) {
|
|||
});
|
||||
|
||||
const userId = params.userId ? params.userId : integrations[0].userId;
|
||||
const user = Users.findOne(userId);
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
const text = `${params.user} ${TAPi18n.__(
|
||||
description,
|
||||
quoteParams,
|
||||
|
|
|
@ -18,10 +18,10 @@ Meteor.publish('boards', function() {
|
|||
|
||||
// Defensive programming to verify that starredBoards has the expected
|
||||
// format -- since the field is in the `profile` a user can modify it.
|
||||
// const { starredBoards = [] } = (Users.findOne(userId) || {}).profile || {};
|
||||
// const { starredBoards = [] } = (ReactiveCache.getUser(userId) || {}).profile || {};
|
||||
// check(starredBoards, [String]);
|
||||
|
||||
// let currUser = Users.findOne(userId);
|
||||
// let currUser = ReactiveCache.getUser(userId);
|
||||
// let orgIdsUserBelongs = currUser!== 'undefined' && currUser.teams !== 'undefined' ? currUser.orgIdsUserBelongs() : '';
|
||||
// let teamIdsUserBelongs = currUser!== 'undefined' && currUser.teams !== 'undefined' ? currUser.teamIdsUserBelongs() : '';
|
||||
// let orgsIds = [];
|
||||
|
@ -165,7 +165,7 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
|
|||
check(isArchived, Boolean);
|
||||
const thisUserId = this.userId;
|
||||
const $or = [{ permission: 'public' }];
|
||||
let currUser = (!Match.test(thisUserId, String) || !thisUserId) ? 'undefined' : Users.findOne(thisUserId);
|
||||
let currUser = (!Match.test(thisUserId, String) || !thisUserId) ? 'undefined' : ReactiveCache.getUser(thisUserId);
|
||||
let orgIdsUserBelongs = currUser!== 'undefined' && currUser.teams !== 'undefined' ? currUser.orgIdsUserBelongs() : '';
|
||||
let teamIdsUserBelongs = currUser!== 'undefined' && currUser.teams !== 'undefined' ? currUser.teamIdsUserBelongs() : '';
|
||||
let orgsIds = [];
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Meteor.publish('org', function(query, limit) {
|
||||
check(query, Match.OneOf(Object, null));
|
||||
check(limit, Number);
|
||||
|
||||
if (!Match.test(this.userId, String)) {
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const user = Users.findOne(this.userId);
|
||||
if (user && user.isAdmin) {
|
||||
return Org.find(query, {
|
||||
limit,
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Meteor.publish('people', function(query, limit) {
|
||||
check(query, Match.OneOf(Object, null));
|
||||
check(limit, Number);
|
||||
|
||||
if (!Match.test(this.userId, String)) {
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const user = Users.findOne(this.userId);
|
||||
if (user && user.isAdmin) {
|
||||
return Users.find(query, {
|
||||
limit,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Meteor.publish('globalwebhooks', () => {
|
||||
const boardId = Integrations.Const.GLOBAL_WEBHOOK_ID;
|
||||
return Integrations.find({
|
||||
|
@ -37,8 +39,10 @@ Meteor.publish('setting', () => {
|
|||
});
|
||||
|
||||
Meteor.publish('mailServer', function() {
|
||||
if (!Match.test(this.userId, String)) return [];
|
||||
const user = Users.findOne(this.userId);
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
if (user && user.isAdmin) {
|
||||
return Settings.find(
|
||||
{},
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Meteor.publish('team', function(query, limit) {
|
||||
check(query, Match.OneOf(Object, null));
|
||||
check(limit, Number);
|
||||
|
||||
if (!Match.test(this.userId, String)) {
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const user = Users.findOne(this.userId);
|
||||
if (user && user.isAdmin) {
|
||||
return Team.find(query, {
|
||||
limit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue