From eaab9bb21be05853a8687f4180a31bdad657aa0e Mon Sep 17 00:00:00 2001 From: Travis Eden Date: Mon, 22 Oct 2018 18:16:38 -0400 Subject: [PATCH] fix update parsing issue --- .../api/claim/publish/parsePublishApiRequestFiles.js | 12 +++++++++++- server/controllers/api/claim/update/index.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js b/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js index d5b447b8..6e1f3409 100644 --- a/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js +++ b/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js @@ -3,7 +3,17 @@ const validateFileTypeAndSize = require('./validateFileTypeAndSize.js'); const parsePublishApiRequestFiles = ({file, thumbnail}, isUpdate) => { // make sure a file was provided - if (!file && !isUpdate) { + if (!file) { + if (isUpdate) { + if (thumbnail) { + const obj = {}; + obj.thumbnailFileName = thumbnail.name; + obj.thumbnailFilePath = thumbnail.path; + obj.thumbnailFileType = thumbnail.type; + return obj; + } + return {}; + } throw new Error('no file with key of [file] found in request'); } if (!file.path) { diff --git a/server/controllers/api/claim/update/index.js b/server/controllers/api/claim/update/index.js index ab2e2f25..bd3a262d 100644 --- a/server/controllers/api/claim/update/index.js +++ b/server/controllers/api/claim/update/index.js @@ -66,7 +66,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res) try { ({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body)); - ({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files)); + ({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files, true)); ({channelName, channelId, channelPassword} = body); } catch (error) { return res.status(400).json({success: false, message: error.message});