From 98cd9e354932f9415f39132f6c8326b095b0be4a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 30 Nov 2020 16:53:16 -0500 Subject: [PATCH] feat: allow uploadThumb controller to be called in code it, and uploadsController.upload() now return the results of their operation --- src/controllers/uploads.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index df1f930401..dc6e744807 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -31,6 +31,7 @@ uploadsController.upload = async function (req, res, filesIterator) { images.push(await filesIterator(fileObj)); } res.status(200).json(images); + return images; } catch (err) { res.status(500).json({ path: req.path, error: err.message }); } finally { @@ -112,7 +113,7 @@ uploadsController.uploadThumb = async function (req, res, next) { return next(new Error('[[error:topic-thumbnails-are-disabled]]')); } - await uploadsController.upload(req, res, async function (uploadedFile) { + return await uploadsController.upload(req, res, async function (uploadedFile) { if (!uploadedFile.type.match(/image./)) { throw new Error('[[error:invalid-file]]'); }