2021-10-16 03:07:13 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import { PadsSessions } from '/imports/api/pads';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
export default async function deleteSession(meetingId, externalId, userId, sessionId) {
|
2021-10-16 03:07:13 +08:00
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(externalId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(sessionId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$pull: {
|
|
|
|
sessions: {
|
|
|
|
[externalId] : sessionId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
await PadsSessions.upsertAsync(selector, modifier);
|
2021-10-16 03:07:13 +08:00
|
|
|
Logger.debug(`Removed pad session=${sessionId} external=${externalId} user=${userId} meeting=${meetingId}`);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Removing pad session to the collection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|