chore: remove deprecated v2 style responses for thumbs upload route [breaking]

v1.18.x
Julian Lam 4 years ago
parent 2ad0d0d0d8
commit 84dfdfe659

@ -23,12 +23,9 @@ uploadsController.upload = async function (req, res, filesIterator) {
return helpers.formatApiResponse(400, res); return helpers.formatApiResponse(400, res);
} }
// TODO: Remove this (and the usages of isV2 below) in v1.17.0
const isV2 = req.originalUrl === `${nconf.get('relative_path')}/api/v2/util/upload`;
// These checks added because of odd behaviour by request: https://github.com/request/request/issues/2445 // These checks added because of odd behaviour by request: https://github.com/request/request/issues/2445
if (!Array.isArray(files)) { if (!Array.isArray(files)) {
return isV2 ? res.status(500).json('invalid files') : helpers.formatApiResponse(500, res, new Error('[[error:invalid-file]]')); return helpers.formatApiResponse(500, res, new Error('[[error:invalid-file]]'));
} }
if (Array.isArray(files[0])) { if (Array.isArray(files[0])) {
files = files[0]; files = files[0];
@ -41,19 +38,11 @@ uploadsController.upload = async function (req, res, filesIterator) {
images.push(await filesIterator(fileObj)); images.push(await filesIterator(fileObj));
} }
if (isV2) {
res.status(200).json(images);
} else {
helpers.formatApiResponse(200, res, { images }); helpers.formatApiResponse(200, res, { images });
}
return images; return images;
} catch (err) { } catch (err) {
if (isV2) {
res.status(500).json({ path: req.path, error: err.message });
} else {
return helpers.formatApiResponse(500, res, err); return helpers.formatApiResponse(500, res, err);
}
} finally { } finally {
deleteTempFiles(files); deleteTempFiles(files);
} }

Loading…
Cancel
Save