From 06ea8009a54052c269242c5bb090c6fb6e363745 Mon Sep 17 00:00:00 2001 From: Sergey Peshkov Date: Fri, 22 Nov 2019 18:25:06 +0300 Subject: [PATCH] fix(event): fixed event editing. Fixes MEMB-740 --- lib/events.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/events.js b/lib/events.js index 7dea5361..1de5110e 100644 --- a/lib/events.js +++ b/lib/events.js @@ -160,14 +160,18 @@ exports.editEvent = async (req, res) => { const data = req.body; const event = req.event; + delete data.id; delete data.status; - delete event.deleted; + delete data.deleted; if (Object.keys(data).length === 0) { return errors.makeValidationError(res, 'No valid field changes requested'); } - event.organizers = await Promise.all(event.organizers.map((organizer) => core.fetchUser(organizer, req.headers['x-auth-token']))); + if (Array.isArray(data.organizers)) { + data.organizers = await Promise.all(data.organizers.map( + (organizer) => core.fetchUser(organizer, req.headers['x-auth-token']))); + } await event.update(data);