2022-05-14 03:18:51 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Users from '/imports/api/users';
|
|
|
|
|
|
|
|
export default function updateUserConnectionId(meetingId, userId, connectionId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(connectionId, String);
|
|
|
|
|
|
|
|
const selector = { meetingId, userId };
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
currentConnectionId: connectionId,
|
2022-05-18 00:09:41 +08:00
|
|
|
connectionIdUpdateTime: new Date().getTime(),
|
2022-05-14 03:18:51 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const User = Users.findOne(selector);
|
|
|
|
|
|
|
|
if (User) {
|
|
|
|
try {
|
|
|
|
const updated = Users.update(selector, modifier);
|
|
|
|
|
|
|
|
if (updated) {
|
|
|
|
Logger.info(`Updated connection user=${userId} connectionid=${connectionId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Updating user connection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|