2017-07-14 22:18:46 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import flat from 'flat';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Screenshare from '/imports/api/screenshare';
|
2017-07-14 22:18:46 +08:00
|
|
|
|
2023-03-17 02:13:43 +08:00
|
|
|
export default async function addScreenshare(meetingId, body) {
|
2017-07-14 22:18:46 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
meetingId,
|
2017-07-27 23:27:06 +08:00
|
|
|
screenshare: flat(body),
|
2017-07-14 22:18:46 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
try {
|
2023-03-17 02:13:43 +08:00
|
|
|
const { numberAffected } = await Screenshare.upsertAsync(selector, modifier);
|
2017-07-14 22:18:46 +08:00
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Upserted screenshare id=${body.screenshareConf}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2020-12-01 04:01:41 +08:00
|
|
|
Logger.error(`Adding screenshare to collection: ${err}`);
|
2020-11-25 21:54:18 +08:00
|
|
|
}
|
2017-07-14 22:18:46 +08:00
|
|
|
}
|