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

35 lines
911 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 async function createDummyUser(meetingId, userId, authToken) {
2017-06-19 21:13:35 +08:00
check(meetingId, String);
check(userId, String);
check(authToken, String);
const User = await Users.findOneAsync({ meetingId, userId });
2017-06-29 02:34:22 +08:00
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 = await Users.insertAsync(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
}