2019-06-29 04:52:19 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Users from '/imports/api/users';
|
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
export default async function changePresenter(presenter, userId, meetingId, changedBy) {
|
2019-06-29 04:52:19 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
presenter,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
2023-03-15 21:18:31 +08:00
|
|
|
const numberAffected = await Users.updateAsync(selector, modifier);
|
2019-06-29 04:52:19 +08:00
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Changed presenter=${presenter} id=${userId} meeting=${meetingId}`
|
|
|
|
+ `${changedBy ? ` changedBy=${changedBy}` : ''}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2021-06-22 02:16:01 +08:00
|
|
|
Logger.error(`Change presenter error: ${err}`);
|
2019-12-19 05:40:04 +08:00
|
|
|
}
|
2019-06-29 04:52:19 +08:00
|
|
|
}
|