fix update parsing issue

This commit is contained in:
Travis Eden 2018-10-22 18:16:38 -04:00
parent 9ba4c4641e
commit eaab9bb21b
2 changed files with 12 additions and 2 deletions

View file

@ -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) {

View file

@ -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});