Merge pull request #13773 from ramonlsouza/remove-persistent-on-leave

Remove unused user data on leave
This commit is contained in:
Anton Georgiev 2021-12-02 15:37:34 -05:00 committed by GitHub
commit 8bbb2b3cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

View File

@ -17,6 +17,7 @@ export default function upsertValidationState(meetingId, userId, validationStatu
};
try {
AuthTokenValidation.remove({ meetingId, userId, connectionId: { $ne: connectionId } });
const { numberAffected } = AuthTokenValidation.upsert(selector, modifier);
if (numberAffected) {

View File

@ -2,6 +2,7 @@ import { Match, check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { GroupChatMsg } from '/imports/api/group-chat-msg';
import { BREAK_LINE } from '/imports/utils/lineEndings';
import changeHasMessages from '/imports/api/users/server/modifiers/changeHasMessages';
export function parseMessage(message) {
let parsedMessage = message || '';
@ -47,6 +48,8 @@ export default function addGroupChatMsg(meetingId, chatId, msg) {
if (insertedId) {
Logger.info(`Added group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
changeHasMessages(true, sender.id, meetingId);
}
} catch (err) {
Logger.error(`Error on adding group-chat-msg to collection: ${err}`);

View File

@ -0,0 +1,25 @@
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
export default function changeHasMessages(hasMessages, userId, meetingId) {
const selector = {
meetingId,
userId,
};
const modifier = {
$set: {
hasMessages,
},
};
try {
const numberAffected = Users.update(selector, modifier);
if (numberAffected) {
Logger.info(`Changed hasMessages=${hasMessages} id=${userId} meeting=${meetingId}`);
}
} catch (err) {
Logger.error(`Change hasMessages error: ${err}`);
}
}

View File

@ -1,5 +1,7 @@
import { check } from 'meteor/check';
import Users from '/imports/api/users';
import UsersPersistentData from '/imports/api/users-persistent-data';
import VoiceUsers from '/imports/api/voice-users/';
import VideoStreams from '/imports/api/video-streams';
import Logger from '/imports/startup/server/logger';
import setloggedOutStatus from '/imports/api/users-persistent-data/server/modifiers/setloggedOutStatus';
@ -44,7 +46,14 @@ export default function removeUser(meetingId, userId) {
clearUserInfoForRequester(meetingId, userId);
const currentUser = Users.findOne({ userId, meetingId });
const hasMessages = currentUser?.hasMessages;
if (!hasMessages) {
UsersPersistentData.remove(selector);
}
Users.remove(selector);
VoiceUsers.remove({ intId: userId, meetingId })
Logger.info(`Removed user id=${userId} meeting=${meetingId}`);
} catch (err) {