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
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
|
|
|
const { numberAffected } = Users.update(selector, modifier);
|
2017-09-21 05:05:17 +08:00
|
|
|
|
2020-11-23 21:13:46 +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
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Changing user lock setting: ${err}`);
|
|
|
|
}
|
2017-09-12 03:11:03 +08:00
|
|
|
}
|