2021-04-09 10:58:13 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import VideoStreams from '/imports/api/video-streams';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
2023-03-20 20:23:39 +08:00
|
|
|
export default async function floorChanged(
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
floor,
|
|
|
|
lastFloorTime,
|
|
|
|
) {
|
2021-04-09 10:58:13 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(floor, Boolean);
|
|
|
|
check(lastFloorTime, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
2023-03-20 20:23:39 +08:00
|
|
|
};
|
2021-04-09 10:58:13 +08:00
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
floor,
|
|
|
|
lastFloorTime: floor ? lastFloorTime : undefined,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
2023-03-20 20:23:39 +08:00
|
|
|
const numberAffected = await VideoStreams.updateAsync(selector, modifier, { multi: true });
|
2021-04-09 10:58:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Updated user streams floor times userId=${userId} floor=${floor} lastFloorTime=${lastFloorTime}`);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
return Logger.error(`Error updating stream floor status: ${error}`);
|
|
|
|
}
|
|
|
|
}
|