2017-09-01 23:26:57 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-11-11 11:41:37 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-11-18 02:55:59 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-09-01 23:26:57 +08:00
|
|
|
|
|
|
|
export default function sharedWebcam(meetingId, userId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
2017-09-19 21:53:27 +08:00
|
|
|
has_stream: true,
|
2017-09-01 23:26:57 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Adding user to collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
|
|
|
return Logger.info(`Upserted user id=${userId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return Users.upsert(selector, modifier, cb);
|
|
|
|
}
|