Fix mobile user-list identification
Added the missing extractCredential method and replaced the old callback strategy with the new try-catch block.
This commit is contained in:
parent
1e943c5a3c
commit
d7c0975b61
@ -2,9 +2,10 @@ import { Meteor } from 'meteor/meteor';
|
|||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
import Logger from '/imports/startup/server/logger';
|
import Logger from '/imports/startup/server/logger';
|
||||||
import setMobile from '../modifiers/setMobile';
|
import setMobile from '../modifiers/setMobile';
|
||||||
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||||
|
|
||||||
export default function setMobileUser(credentials) {
|
export default function setMobileUser() {
|
||||||
const { meetingId, requesterUserId } = credentials;
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||||
|
|
||||||
check(meetingId, String);
|
check(meetingId, String);
|
||||||
check(requesterUserId, String);
|
check(requesterUserId, String);
|
||||||
|
@ -3,9 +3,6 @@ import { check } from 'meteor/check';
|
|||||||
import Users from '/imports/api/users';
|
import Users from '/imports/api/users';
|
||||||
|
|
||||||
export default function setMobile(meetingId, userId) {
|
export default function setMobile(meetingId, userId) {
|
||||||
check(meetingId, String);
|
|
||||||
check(userId, String);
|
|
||||||
|
|
||||||
const selector = {
|
const selector = {
|
||||||
meetingId,
|
meetingId,
|
||||||
userId,
|
userId,
|
||||||
@ -17,16 +14,13 @@ export default function setMobile(meetingId, userId) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const cb = (err, numChanged) => {
|
try {
|
||||||
if (err) {
|
const numberAffected = Users.update(selector, modifier);
|
||||||
Logger.error(`Assigning mobile user: ${err}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numChanged) {
|
if (numberAffected) {
|
||||||
Logger.info(`Assigned mobile user id=${userId} meeting=${meetingId}`);
|
Logger.info(`Assigned mobile user id=${userId} meeting=${meetingId}`);
|
||||||
}
|
}
|
||||||
};
|
} catch (err) {
|
||||||
|
Logger.error(`Assigning mobile user: ${err}`);
|
||||||
return Users.update(selector, modifier, cb);
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user