diff --git a/controllers/apps.js b/controllers/apps.js index b976d45..6948401 100644 --- a/controllers/apps.js +++ b/controllers/apps.js @@ -16,24 +16,20 @@ exports.createApp = asyncWrapper(async (req, res, next) => { const pinApps = await Config.findOne({ where: { key: 'pinAppsByDefault' }, }); - + let app; - let _body = { ...req.body }; + + let _body = { + ...req.body, + categoryId: parseInt(req.body.categoryId), + isPinned: (pinApps && parseInt(pinApps.value)), + }; if (req.file) { _body.icon = req.file.filename; } - if (pinApps) { - if (parseInt(pinApps.value)) { - app = await App.create({ - ..._body, - isPinned: true, - }); - } else { - app = await App.create(req.body); - } - } + app = await App.create(_body); res.status(201).json({ success: true, diff --git a/controllers/bookmark.js b/controllers/bookmark.js index 9fe6097..d29b08d 100644 --- a/controllers/bookmark.js +++ b/controllers/bookmark.js @@ -10,20 +10,14 @@ const { Sequelize } = require('sequelize'); exports.createBookmark = asyncWrapper(async (req, res, next) => { const pinBookmarks = await Config.findOne({ where: { key: 'pinBookmarksByDefault' } - }); + }); let bookmark; - let _body = { ...req.body }; - - if (req.file) { - _body.icon = req.file.filename; - } - let _body = { ...req.body, categoryId: parseInt(req.body.categoryId), - isPinned = (pinBookmarks && parseInt(pinBookmarks.value)), + isPinned: (pinBookmarks && parseInt(pinBookmarks.value)), }; if (req.file) {