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

35 lines
883 B
JavaScript
Raw Normal View History

2017-06-19 21:13:35 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
2017-06-19 21:13:35 +08:00
export default function createDummyUser(meetingId, userId, authToken) {
2017-06-19 21:13:35 +08:00
check(meetingId, String);
check(userId, String);
check(authToken, String);
2017-06-29 02:34:22 +08:00
const User = Users.findOne({ meetingId, userId });
if (User) {
2017-06-19 21:13:35 +08:00
throw new Meteor.Error('existing-user', 'Tried to create a dummy user for an existing user');
}
const doc = {
meetingId,
userId,
authToken,
clientType: 'HTML5',
validated: null,
2022-01-07 22:37:23 +08:00
left: false,
2017-06-19 21:13:35 +08:00
};
try {
const insertedId = Users.insert(doc);
if (insertedId) {
2017-12-13 23:45:54 +08:00
Logger.info(`Created dummy user id=${userId} token=${authToken} meeting=${meetingId}`);
2017-06-19 21:13:35 +08:00
}
} catch (err) {
Logger.error(`Creating dummy user to collection: ${err}`);
}
2017-06-19 21:13:35 +08:00
}