2021-03-20 04:12:27 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import UsersPersistentData from '/imports/api/users-persistent-data/index';
|
|
|
|
|
2023-03-20 21:21:34 +08:00
|
|
|
export default async function clearUsersPersistentData(meetingId) {
|
2021-03-20 04:12:27 +08:00
|
|
|
if (meetingId) {
|
|
|
|
try {
|
2023-03-20 21:21:34 +08:00
|
|
|
const numberAffected = await UsersPersistentData.removeAsync({ meetingId });
|
2021-03-20 04:12:27 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared users persistent data (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error clearing users persistent data (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-20 21:21:34 +08:00
|
|
|
const numberAffected = await UsersPersistentData.removeAsync({});
|
2021-03-20 04:12:27 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared users persistent data (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error clearing users persistent data (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|