Node.js based forum software built for the modern web
feat: closes https://github.com/NodeBB/NodeBB/pull/11970
Barış Soner Uşaklı007efc21d42d
diff --git a/src/controllers/admin/uploads.js b/src/controllers/admin/uploads.jsindex c8e8075456..f8c8bdf3f6 100644--- a/src/controllers/admin/uploads.js+++ b/src/controllers/admin/uploads.js@@ -168,14 +168,8 @@ uploadsController.uploadFavicon = async function (req, res, next) {const allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'];await validateUpload(uploadedFile, allowedTypes);- try {- const imageObj = await file.saveFileToLocal('favicon.ico', 'system', uploadedFile.path);- res.json([{ name: uploadedFile.name, url: imageObj.url }]);- } catch (err) {- next(err);- } finally {- file.delete(uploadedFile.path);- }+ const filename = 'favicon' + path.extname(uploadedFile.name);+ await uploadImage(filename, 'system', uploadedFile, req, res, next);};uploadsController.uploadTouchIcon = async function (req, res, next) {@@ -274,7 +268,11 @@ async function uploadImage(filename, folder, uploadedFile, req, res, next) {let imageData;try {if (plugins.hooks.hasListeners('filter:uploadImage')) {- imageData = await plugins.hooks.fire('filter:uploadImage', { image: uploadedFile, uid: req.uid, folder: folder });+ imageData = await plugins.hooks.fire('filter:uploadImage', {+ image: uploadedFile,+ uid: req.uid,+ folder: folder,+ });} else {imageData = await file.saveFileToLocal(filename, folder, uploadedFile.path);}@@ -299,7 +297,14 @@ async function uploadImage(filename, folder, uploadedFile, req, res, next) {'og:image:height': size.height,});}- res.json([{ name: uploadedFile.name, url: imageData.url.startsWith('http') ? imageData.url : nconf.get('relative_path') + imageData.url }]);+ res.json([+ {+ name: uploadedFile.name,+ url: imageData.url.startsWith('http') ?+ imageData.url :+ nconf.get('relative_path') + imageData.url,+ },+ ]);} catch (err) {next(err);} finally {diff --git a/src/meta/tags.js b/src/meta/tags.jsindex b59760b167..5afac6236d 100644--- a/src/meta/tags.js+++ b/src/meta/tags.js@@ -57,8 +57,8 @@ Tags.parse = async (req, data, meta, link) => {});}- const faviconPath = `${relative_path}/assets/uploads/system/favicon.ico`;- const cacheBuster = `${Meta.config['cache-buster'] ? `?${Meta.config['cache-buster']}` : ''}`;+ const faviconPath = Meta.config['brand:favicon'] || `${relative_path}/assets/uploads/system/favicon.ico`;+ const cacheBuster = Meta.config['cache-buster'] || '';// Link Tagsconst defaultLinks = isAPI ? [] : [{