mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every InvitationCodes.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
49071ca5fd
commit
76aae41637
3 changed files with 55 additions and 5 deletions
|
@ -163,6 +163,14 @@ ReactiveCacheServer = {
|
|||
const ret = SessionData.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getInvitationCode(idOrFirstObjectSelector, options) {
|
||||
const ret = InvitationCodes.findOne(idOrFirstObjectSelector, options);
|
||||
return ret;
|
||||
},
|
||||
getInvitationCodes(selector, options) {
|
||||
const ret = InvitationCodes.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
const ret = Settings.findOne();
|
||||
return ret;
|
||||
|
@ -633,6 +641,30 @@ ReactiveCacheClient = {
|
|||
const ret = this.__integrations.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getInvitationCode(idOrFirstObjectSelector, options) {
|
||||
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||
if (!this.__invitationCode) {
|
||||
this.__invitationCode = new DataCache(_idOrFirstObjectSelect => {
|
||||
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||
const _ret = InvitationCodes.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__invitationCode.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||
return ret;
|
||||
},
|
||||
getInvitationCodes(selector, options) {
|
||||
const select = {selector, options}
|
||||
if (!this.__invitationCodes) {
|
||||
this.__invitationCodes = new DataCache(_select => {
|
||||
const __select = Jsons.parse(_select);
|
||||
const _ret = InvitationCodes.find(__select.selector, __select.options).fetch();
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__invitationCodes.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||
this.__currentSetting = new DataCache(() => {
|
||||
|
@ -1014,6 +1046,24 @@ ReactiveCache = {
|
|||
let ret = ReactiveCacheServer.getSessionDatas(selector, options);
|
||||
return ret;
|
||||
},
|
||||
getInvitationCode(idOrFirstObjectSelector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getInvitationCode(idOrFirstObjectSelector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getInvitationCode(idOrFirstObjectSelector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getInvitationCodes(selector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getInvitationCodes(selector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getInvitationCodes(selector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -249,7 +249,7 @@ if (Meteor.isServer) {
|
|||
}
|
||||
|
||||
function sendInvitationEmail(_id) {
|
||||
const icode = InvitationCodes.findOne(_id);
|
||||
const icode = ReactiveCache.getInvitationCode(_id);
|
||||
const author = ReactiveCache.getCurrentUser();
|
||||
try {
|
||||
const fullName = ReactiveCache.getUser(icode.authorId)?.profile?.fullname || "";
|
||||
|
@ -358,7 +358,7 @@ if (Meteor.isServer) {
|
|||
);
|
||||
}
|
||||
// Checks if the email is already link to an invitation.
|
||||
const invitation = InvitationCodes.findOne({ email });
|
||||
const invitation = ReactiveCache.getInvitationCode({ email });
|
||||
if (invitation) {
|
||||
InvitationCodes.update(invitation, {
|
||||
$set: { boardsToBeInvited: boards },
|
||||
|
|
|
@ -1671,7 +1671,7 @@ if (Meteor.isServer) {
|
|||
'The invitation code is required',
|
||||
);
|
||||
}
|
||||
const invitationCode = InvitationCodes.findOne({
|
||||
const invitationCode = ReactiveCache.getInvitationCode({
|
||||
code: options.profile.invitationcode,
|
||||
email: options.email,
|
||||
valid: true,
|
||||
|
@ -1963,12 +1963,12 @@ if (Meteor.isServer) {
|
|||
let invitationCode = null;
|
||||
if (doc.authenticationMethod.toLowerCase() == 'oauth2') {
|
||||
// OIDC authentication mode
|
||||
invitationCode = InvitationCodes.findOne({
|
||||
invitationCode = ReactiveCache.getInvitationCode({
|
||||
email: doc.emails[0].address.toLowerCase(),
|
||||
valid: true,
|
||||
});
|
||||
} else {
|
||||
invitationCode = InvitationCodes.findOne({
|
||||
invitationCode = ReactiveCache.getInvitationCode({
|
||||
code: doc.profile.icode,
|
||||
valid: true,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue