mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01: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
|
|
@ -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