From ad48962c335f6cec25bcedb92b4c34b6e4b0522c Mon Sep 17 00:00:00 2001 From: Vijay A Date: Mon, 16 May 2022 17:29:24 -0500 Subject: Minor refactoring to extract common function to deduce icon url --- src/internal-server/app/ImageHelper.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/internal-server/app/ImageHelper.js') diff --git a/src/internal-server/app/ImageHelper.js b/src/internal-server/app/ImageHelper.js index b399d08c4..e7c981a1d 100644 --- a/src/internal-server/app/ImageHelper.js +++ b/src/internal-server/app/ImageHelper.js @@ -4,8 +4,9 @@ const { v4: uuid } = require('uuid'); const path = require('path'); const fs = require('fs-extra'); +const { API_VERSION } = require('../../environment-remote'); -module.exports = async (icon) => { +const moveIcon = async (icon) => { const iconsPath = path.join(Env.get('USER_PATH'), 'icons'); await fs.ensureDir(iconsPath); @@ -22,3 +23,7 @@ module.exports = async (icon) => { }); return !icon.moved() ? '-1' : iconId; }; + +const deduceIconUrl = (iconId) => iconId ? `http://${Env.get('HOST')}:${Env.get('PORT')}/${API_VERSION}/icon/${iconId}` : null + +module.exports = { moveIcon, deduceIconUrl }; -- cgit v1.2.3-70-g09d2