remove user data when not needed
This commit is contained in:
parent
457175dbba
commit
c5e9b3a02f
@ -1,6 +1,7 @@
|
||||
import ConnectionStatus from '/imports/api/connection-status';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { check } from 'meteor/check';
|
||||
import changeHasConnectionStatus from '/imports/api/users-persistent-data/server/modifiers/changeHasConnectionStatus';
|
||||
|
||||
export default function updateConnectionStatus(meetingId, userId, level) {
|
||||
check(meetingId, String);
|
||||
@ -24,6 +25,7 @@ export default function updateConnectionStatus(meetingId, userId, level) {
|
||||
const { numberAffected } = ConnectionStatus.upsert(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
changeHasConnectionStatus(true, userId, meetingId);
|
||||
Logger.verbose(`Updated connection status meetingId=${meetingId} userId=${userId} level=${level}`);
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -0,0 +1,25 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import UsersPersistentData from '/imports/api/users-persistent-data';
|
||||
|
||||
export default function changeHasConnectionStatus(hasConnectionStatus, userId, meetingId) {
|
||||
const selector = {
|
||||
meetingId,
|
||||
userId,
|
||||
};
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
'shouldPersist.hasConnectionStatus': hasConnectionStatus,
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const numberAffected = UsersPersistentData.update(selector, modifier);
|
||||
|
||||
if (numberAffected) {
|
||||
Logger.info(`Changed hasConnectionStatus=${hasConnectionStatus} id=${userId} meeting=${meetingId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Change hasConnectionStatus error: ${err}`);
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ export default function changeHasMessages(hasMessages, userId, meetingId) {
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
hasMessages,
|
||||
'shouldPersist.hasMessages': hasMessages,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ function usersPersistentData() {
|
||||
meetingId,
|
||||
$or: [
|
||||
{
|
||||
hasMessages: true,
|
||||
'shouldPersist.hasMessages': true,
|
||||
},
|
||||
{
|
||||
loggedOut: false,
|
||||
|
@ -5,6 +5,7 @@ import Logger from '/imports/startup/server/logger';
|
||||
import setloggedOutStatus from '/imports/api/users-persistent-data/server/modifiers/setloggedOutStatus';
|
||||
import clearUserInfoForRequester from '/imports/api/users-infos/server/modifiers/clearUserInfoForRequester';
|
||||
import ClientConnections from '/imports/startup/server/ClientConnections';
|
||||
import UsersPersistentData from '/imports/api/users-persistent-data';
|
||||
import VoiceUsers from '/imports/api/voice-users/';
|
||||
|
||||
const clearAllSessions = (sessionUserId) => {
|
||||
@ -36,7 +37,13 @@ export default function removeUser(meetingId, userId) {
|
||||
|
||||
clearUserInfoForRequester(meetingId, userId);
|
||||
|
||||
|
||||
const currentUser = UsersPersistentData.findOne({ userId, meetingId });
|
||||
const hasMessages = currentUser?.shouldPersist?.hasMessages;
|
||||
const hasConnectionStatus = currentUser?.shouldPersist?.hasConnectionStatus;
|
||||
|
||||
if (!hasMessages && !hasConnectionStatus) {
|
||||
UsersPersistentData.remove(selector);
|
||||
}
|
||||
Users.remove(selector);
|
||||
VoiceUsers.remove({ intId: userId, meetingId });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user