2022-10-07 20:15:00 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
import setUserExitReason from '/imports/api/users/server/modifiers/setUserExitReason';
|
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
export default async function setExitReason(reason) {
|
2022-10-07 20:15:00 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
2022-10-08 03:21:43 +08:00
|
|
|
// Unauthenticated user, just ignore and go ahead.
|
|
|
|
if (!meetingId || !requesterUserId) return;
|
|
|
|
|
2022-10-07 20:15:00 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(reason, String);
|
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
await setUserExitReason(meetingId, requesterUserId, reason);
|
2022-10-07 20:15:00 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method setExitReason ${err.stack}`);
|
|
|
|
}
|
2023-03-15 21:18:31 +08:00
|
|
|
}
|