2017-10-07 00:10:23 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-10-07 00:10:23 +08:00
|
|
|
|
2019-06-29 04:52:19 +08:00
|
|
|
export default function changeRole(role, userId, meetingId, changedBy) {
|
2017-10-07 00:10:23 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2019-06-29 04:52:19 +08:00
|
|
|
role,
|
2017-10-07 00:10:23 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
|
|
|
const numberAffected = Users.update(selector, modifier);
|
2017-10-07 00:10:23 +08:00
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Changed user role=${role} id=${userId} meeting=${meetingId}`
|
|
|
|
+ `${changedBy ? ` changedBy=${changedBy}` : ''}`);
|
2017-10-07 00:10:23 +08:00
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Changed user role: ${err}`);
|
|
|
|
}
|
2017-10-07 00:10:23 +08:00
|
|
|
}
|