2021-04-07 03:32:04 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import UsersPersistentData from '/imports/api/users-persistent-data';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-20 21:21:34 +08:00
|
|
|
export default async function updateRole(userId, meetingId, role) {
|
2021-04-07 03:32:04 +08:00
|
|
|
check(userId, String);
|
|
|
|
check(meetingId, String);
|
|
|
|
check(role, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
userId,
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
role,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
2023-03-20 21:21:34 +08:00
|
|
|
await UsersPersistentData.updateAsync(selector, modifier);
|
2021-04-07 03:32:04 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Updating users persistent data's role to the collection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|