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 Logger from '/imports/startup/server/logger';
|
||||
import setMobile from '../modifiers/setMobile';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
export default function setMobileUser(credentials) {
|
||||
const { meetingId, requesterUserId } = credentials;
|
||||
export default function setMobileUser() {
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
|
@ -3,9 +3,6 @@ import { check } from 'meteor/check';
|
||||
import Users from '/imports/api/users';
|
||||
|
||||
export default function setMobile(meetingId, userId) {
|
||||
check(meetingId, String);
|
||||
check(userId, String);
|
||||
|
||||
const selector = {
|
||||
meetingId,
|
||||
userId,
|
||||
@ -17,16 +14,13 @@ export default function setMobile(meetingId, userId) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
Logger.error(`Assigning mobile user: ${err}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const numberAffected = Users.update(selector, modifier);
|
||||
|
||||
if (numChanged) {
|
||||
if (numberAffected) {
|
||||
Logger.info(`Assigned mobile user id=${userId} meeting=${meetingId}`);
|
||||
}
|
||||
};
|
||||
|
||||
return Users.update(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Assigning mobile user: ${err}`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user