2020-04-10 01:01:46 +08:00
|
|
|
import ConnectionStatus from '/imports/api/connection-status';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
2022-02-02 21:53:23 +08:00
|
|
|
import changeHasConnectionStatus from '/imports/api/users-persistent-data/server/modifiers/changeHasConnectionStatus';
|
2020-04-10 01:01:46 +08:00
|
|
|
|
|
|
|
export default function updateConnectionStatus(meetingId, userId, level) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
|
|
|
const timestamp = new Date().getTime();
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
2020-05-14 21:35:25 +08:00
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
level,
|
|
|
|
timestamp,
|
2020-04-10 01:01:46 +08:00
|
|
|
};
|
|
|
|
|
2021-03-26 05:22:50 +08:00
|
|
|
try {
|
|
|
|
const { numberAffected } = ConnectionStatus.upsert(selector, modifier);
|
2020-04-10 01:01:46 +08:00
|
|
|
|
2021-03-26 05:22:50 +08:00
|
|
|
if (numberAffected) {
|
2022-02-02 21:53:23 +08:00
|
|
|
changeHasConnectionStatus(true, userId, meetingId);
|
2021-04-27 05:19:17 +08:00
|
|
|
Logger.verbose(`Updated connection status meetingId=${meetingId} userId=${userId} level=${level}`);
|
2020-05-14 21:35:25 +08:00
|
|
|
}
|
2021-03-26 05:22:50 +08:00
|
|
|
} catch (err) {
|
2021-04-27 05:19:17 +08:00
|
|
|
Logger.error(`Updating connection status meetingId=${meetingId} userId=${userId}: ${err}`);
|
2021-03-26 05:22:50 +08:00
|
|
|
}
|
2020-04-10 01:01:46 +08:00
|
|
|
}
|