2017-09-12 03:11:03 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-09-12 03:11:03 +08:00
|
|
|
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;
|
|
|
|
|
2017-09-12 03:11:03 +08:00
|
|
|
const selector = {
|
2019-07-07 07:47:33 +08:00
|
|
|
meetingId,
|
2017-09-21 05:05:17 +08:00
|
|
|
userId,
|
2017-09-12 03:11:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2017-09-21 05:05:17 +08:00
|
|
|
locked,
|
2017-09-12 03:11:03 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-09-21 05:05:17 +08:00
|
|
|
const cb = (err, numChanged) => {
|
2017-09-12 03:11:03 +08:00
|
|
|
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}`);
|
2017-09-12 03:11:03 +08:00
|
|
|
};
|
|
|
|
|
2019-07-07 07:47:33 +08:00
|
|
|
return Users.update(selector, modifier, cb);
|
2017-09-12 03:11:03 +08:00
|
|
|
}
|