bigbluebutton-Github/bigbluebutton-html5/imports/api/users-persistent-data/server/modifiers/addUserPersistentData.js

82 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-03-20 04:12:27 +08:00
import { check } from 'meteor/check';
import UsersPersistentData from '/imports/api/users-persistent-data';
import Logger from '/imports/startup/server/logger';
export default function addUserPersistentData(user) {
check(user, {
meetingId: String,
sortName: String,
color: String,
speechLocale: String,
2021-03-20 04:12:27 +08:00
mobile: Boolean,
breakoutProps: Object,
inactivityCheck: Boolean,
responseDelay: Number,
loggedOut: Boolean,
intId: String,
extId: String,
name: String,
pin: Boolean,
2021-03-20 04:12:27 +08:00
role: String,
guest: Boolean,
authed: Boolean,
waitingForAcceptance: Match.Maybe(Boolean),
2021-03-20 04:12:27 +08:00
guestStatus: String,
emoji: String,
presenter: Boolean,
locked: Boolean,
avatar: String,
clientType: String,
2022-01-07 05:07:22 +08:00
left: Boolean,
2021-03-20 04:12:27 +08:00
effectiveConnectionType: null,
});
const {
intId,
extId,
meetingId,
name,
role,
token,
avatar,
guest,
color,
pin,
2021-03-20 04:12:27 +08:00
} = user;
const userData = {
userId: intId,
extId,
meetingId,
name,
role,
token,
avatar,
guest,
color,
pin,
loggedOut: false,
2021-03-20 04:12:27 +08:00
};
const selector = {
userId: intId,
meetingId,
};
const modifier = {
$set: userData,
};
try {
const { insertedId } = UsersPersistentData.upsert(selector, modifier);
if (insertedId) {
Logger.info(`Added user id=${intId} to user persistent Data: meeting=${meetingId}`);
} else {
Logger.info(`Upserted user id=${intId} to user persistent Data: meeting=${meetingId}`);
}
} catch (err) {
Logger.error(`Adding note to the collection: ${err}`);
}
}