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

38 lines
867 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 async 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,
},
};
try {
const { numberAffected } = Users.updateAsync(selector, modifier);
2017-09-21 05:05:17 +08:00
if (numberAffected) {
Logger.info(`User's userId=${userId} lock status was changed to: ${locked} by user userId=${lockedBy}`);
} else {
Logger.info(`User's userId=${userId} lock status wasn't updated`);
2017-09-21 05:05:17 +08:00
}
} catch (err) {
Logger.error(`Changing user lock setting: ${err}`);
}
}