33 lines
654 B
JavaScript
33 lines
654 B
JavaScript
|
import Logger from '/imports/startup/server/logger';
|
||
|
import Users from '/imports/api/2.0/users';
|
||
|
|
||
|
export default function sharedWebcam(meetingId, userId) {
|
||
|
check(meetingId, String);
|
||
|
check(userId, String);
|
||
|
|
||
|
const selector = {
|
||
|
meetingId,
|
||
|
userId,
|
||
|
};
|
||
|
|
||
|
const modifier = {
|
||
|
$set: {
|
||
|
meetingId,
|
||
|
userId,
|
||
|
'user.has_stream': true,
|
||
|
},
|
||
|
};
|
||
|
|
||
|
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);
|
||
|
}
|