Fix presentations not being removed while non existent in the reply message
This commit is contained in:
parent
cc0999013f
commit
19f119fcf6
@ -1,8 +1,10 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { check } from 'meteor/check';
|
||||
import { inReplyToHTML5Client } from '/imports/api/common/server/helpers';
|
||||
import Presentations from '/imports/api/presentations';
|
||||
|
||||
import addPresentation from '../modifiers/addPresentation';
|
||||
import removePresentation from '../modifiers/removePresentation';
|
||||
|
||||
export default function handlePresentationInfoReply({ payload }) {
|
||||
if (!inReplyToHTML5Client({ payload })) {
|
||||
@ -15,6 +17,14 @@ export default function handlePresentationInfoReply({ payload }) {
|
||||
check(meetingId, String);
|
||||
check(presentations, Array);
|
||||
|
||||
const presentationsIds = presentations.map(_ => _.id);
|
||||
const presentationsToRemove = Presentations.find({
|
||||
meetingId,
|
||||
'presentation.id': { $nin: presentationsIds },
|
||||
}).fetch();
|
||||
|
||||
presentationsToRemove.forEach(p => removePresentation(meetingId, p.presentation.id));
|
||||
|
||||
let presentationsAdded = [];
|
||||
presentations.forEach(presentation => {
|
||||
presentationsAdded.push(addPresentation(meetingId, presentation));
|
||||
|
Loading…
Reference in New Issue
Block a user