2017-07-14 22:18:46 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import flat from 'flat';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Screenshare from '/imports/api/2.0/screenshare';
|
|
|
|
|
2017-07-27 23:27:06 +08:00
|
|
|
export default 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
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err) => {
|
|
|
|
if (err) {
|
2017-07-27 23:27:06 +08:00
|
|
|
return Logger.error(`Adding screenshare to collection: ${err}`);
|
2017-07-14 22:18:46 +08:00
|
|
|
}
|
|
|
|
|
2017-07-27 23:27:06 +08:00
|
|
|
return Logger.info(`Upserted screenshare id=${body.screenshareConf}`);
|
2017-07-14 22:18:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return Screenshare.upsert(selector, modifier, cb);
|
|
|
|
}
|