From 9ce9a1aad96eead4ef9f5163a2d5f8ee478f08ac Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 6 Jun 2023 14:13:17 +0200 Subject: [PATCH] fix media update --- server/api/controller/event.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 4d017652..4863c331 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -33,7 +33,7 @@ const eventController = { const place_address = body.place_address && body.place_address.trim() if (!place_name || !place_address && place_name !== 'online') { throw new Error(`place_id or place_name and place_address are required`) - } + } let place = await Place.findOne({ where: Sequelize.where(Sequelize.fn('LOWER', Sequelize.col('name')), Sequelize.Op.eq, place_name.toLocaleLowerCase()) }) if (!place) { place = await Place.create({ @@ -454,9 +454,7 @@ const eventController = { }] } else if (!body.image) { eventDetails.media = [] - } - - if (body.image_focalpoint && event.media.length) { + } else if (body.image_focalpoint && event.media.length) { let focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0'] focalpoint = [parseFloat(parseFloat(focalpoint[0]).toFixed(2)), parseFloat(parseFloat(focalpoint[1]).toFixed(2))] eventDetails.media = [{ ...event.media[0], focalpoint }] // [0].focalpoint = focalpoint @@ -607,7 +605,7 @@ const eventController = { Sequelize.fn('EXISTS', Sequelize.literal(`SELECT 1 FROM event_tags WHERE ${Col('event_tags.eventId')}=${Col('event.id')} AND LOWER(${Col('tagTag')}) = ?`)) ] } - + let pagination = {} if (limit) { pagination = { @@ -692,7 +690,7 @@ const eventController = { const parentStartDatetime = DateTime.fromSeconds(e.start_datetime) // cursor is when start to count - // sets it to + // sets it to let cursor = parentStartDatetime > startAt ? parentStartDatetime : startAt startAt = cursor