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:
Pedro Beschorner Marin 2021-02-08 09:55:38 -03:00
parent 1e943c5a3c
commit d7c0975b61
2 changed files with 9 additions and 14 deletions

View File

@ -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);

View File

@ -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}`);
}
}