2017-08-01 03:36:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import VoiceUsers from '/imports/api/voice-users';
|
2019-11-15 01:07:02 +08:00
|
|
|
import { clearSpokeTimeout } from '/imports/api/common/server/helpers';
|
2017-08-01 03:36:41 +08:00
|
|
|
|
2023-03-17 02:37:24 +08:00
|
|
|
export default async function removeVoiceUser(meetingId, voiceUser) {
|
2017-08-01 03:36:41 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(voiceUser, {
|
|
|
|
voiceConf: String,
|
|
|
|
voiceUserId: String,
|
2017-08-01 21:10:12 +08:00
|
|
|
intId: String,
|
2017-08-01 03:36:41 +08:00
|
|
|
});
|
|
|
|
|
2017-08-01 21:10:12 +08:00
|
|
|
const { intId } = voiceUser;
|
2017-08-01 03:36:41 +08:00
|
|
|
|
2017-08-01 21:10:12 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
intId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
2017-08-02 21:11:53 +08:00
|
|
|
$set: {
|
|
|
|
muted: false,
|
|
|
|
talking: false,
|
|
|
|
listenOnly: false,
|
|
|
|
joined: false,
|
2019-11-14 00:24:38 +08:00
|
|
|
spoke: false,
|
2017-08-02 21:11:53 +08:00
|
|
|
},
|
2017-08-01 21:10:12 +08:00
|
|
|
};
|
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
try {
|
2023-03-17 02:37:24 +08:00
|
|
|
await clearSpokeTimeout(meetingId, intId);
|
|
|
|
const numberAffected = await VoiceUsers.updateAsync(selector, modifier);
|
2019-11-14 23:58:07 +08:00
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Remove voiceUser=${intId} meeting=${meetingId}`);
|
2017-08-01 21:10:12 +08:00
|
|
|
}
|
2020-11-27 00:23:57 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Remove voiceUser=${intId}: ${err}`);
|
|
|
|
}
|
2017-08-01 03:36:41 +08:00
|
|
|
}
|