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