bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/modifiers/createDummyUser.js

34 lines
877 B
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
2017-10-12 09:02:23 +08:00
import Users from '/imports/api/2.0/users';
2016-05-13 01:43:59 +08:00
2017-10-12 09:02:23 +08:00
export default function createDummyUser2x(meetingId, userId, authToken) {
check(meetingId, String);
check(userId, String);
check(authToken, String);
const User = Users.findOne({ meetingId, userId });
if (User) {
2017-06-03 03:25:02 +08:00
throw new Meteor.Error('existing-user', 'Tried to create a dummy user for an existing user');
2016-05-16 22:35:59 +08:00
}
const doc = {
meetingId,
userId,
authToken,
clientType: 'HTML5',
2017-03-11 03:18:23 +08:00
validated: null,
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Creating dummy user to collection: ${err}`);
}
2017-10-12 09:02:23 +08:00
Logger.info(`Created dummy user 2x id=${userId} token=${authToken} meeting=${meetingId}`);
};
return Users.insert(doc, cb);
2017-06-03 03:25:02 +08:00
}