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';
|
|
|
|
|
2023-03-20 21:21:34 +08:00
|
|
|
export default async function addUserPersistentData(user) {
|
2021-03-20 04:12:27 +08:00
|
|
|
check(user, {
|
|
|
|
meetingId: String,
|
|
|
|
sortName: String,
|
|
|
|
color: String,
|
2022-04-14 21:59:54 +08:00
|
|
|
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,
|
2021-11-29 21:44:14 +08:00
|
|
|
pin: Boolean,
|
2021-03-20 04:12:27 +08:00
|
|
|
role: String,
|
|
|
|
guest: Boolean,
|
|
|
|
authed: Boolean,
|
2021-04-07 05:44:54 +08:00
|
|
|
waitingForAcceptance: Match.Maybe(Boolean),
|
2021-03-20 04:12:27 +08:00
|
|
|
guestStatus: String,
|
|
|
|
emoji: String,
|
2023-06-08 09:10:07 +08:00
|
|
|
reactionEmoji: String,
|
|
|
|
raiseHand: Boolean,
|
|
|
|
away: Boolean,
|
2021-03-20 04:12:27 +08:00
|
|
|
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,
|
2021-11-29 21:44:14 +08:00
|
|
|
pin,
|
2021-03-20 04:12:27 +08:00
|
|
|
} = user;
|
|
|
|
|
|
|
|
const userData = {
|
|
|
|
userId: intId,
|
|
|
|
extId,
|
|
|
|
meetingId,
|
|
|
|
name,
|
|
|
|
role,
|
|
|
|
token,
|
|
|
|
avatar,
|
|
|
|
guest,
|
|
|
|
color,
|
2021-11-29 21:44:14 +08:00
|
|
|
pin,
|
2021-03-23 04:44:53 +08:00
|
|
|
loggedOut: false,
|
2021-03-20 04:12:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
userId: intId,
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: userData,
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
2023-03-20 21:21:34 +08:00
|
|
|
const { insertedId } = await UsersPersistentData.upsertAsync(selector, modifier);
|
2021-03-20 04:12:27 +08:00
|
|
|
|
|
|
|
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}`);
|
|
|
|
}
|
|
|
|
}
|