bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/modifiers/changeUserLock.js

40 lines
877 B
JavaScript
Raw Normal View History

import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import { check } from 'meteor/check';
export default function changeUserLock(meetingId, payload) {
check(meetingId, String);
check(payload, {
userId: String,
locked: Boolean,
lockedBy: String,
});
2017-09-21 05:05:17 +08:00
const { userId, locked, lockedBy } = payload;
const selector = {
2019-07-07 07:47:33 +08:00
meetingId,
2017-09-21 05:05:17 +08:00
userId,
};
const modifier = {
$set: {
2017-09-21 05:05:17 +08:00
locked,
},
};
2017-09-21 05:05:17 +08:00
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Changing user lock setting: ${err}`);
}
2017-09-21 05:05:17 +08:00
if (!numChanged) {
return Logger.info(`User's userId=${userId} lock status wasn't updated`);
}
return Logger.info(`User's userId=${userId} lock status was changed to: ${locked} by user userId=${lockedBy}`);
};
2019-07-07 07:47:33 +08:00
return Users.update(selector, modifier, cb);
}