bigbluebutton-Github/bigbluebutton-html5/imports/api/users-persistent-data/server/modifiers/addUserPersistentData.js
Max Franke 85ad9a5e30 feat(video): webcam video pinning server side logic
Add the new ChangeUserPinState messages to handle the new video pinning
functionality
2021-12-21 16:58:38 -03:00

81 lines
1.5 KiB
JavaScript

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,
mobile: Boolean,
breakoutProps: Object,
inactivityCheck: Boolean,
responseDelay: Number,
loggedOut: Boolean,
intId: String,
extId: String,
name: String,
pin: Boolean,
role: String,
guest: Boolean,
authed: Boolean,
waitingForAcceptance: Match.Maybe(Boolean),
guestStatus: String,
emoji: String,
presenter: Boolean,
locked: Boolean,
avatar: String,
clientType: String,
effectiveConnectionType: null,
});
const {
intId,
extId,
meetingId,
name,
role,
token,
avatar,
guest,
color,
pin,
} = user;
const userData = {
userId: intId,
extId,
meetingId,
name,
role,
token,
avatar,
guest,
color,
pin,
loggedOut: false,
};
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}`);
}
}