Added alert dialog. Fixed image rotation EXIT data being discarded.
This commit is contained in:
23
src/alerts.js
Normal file
23
src/alerts.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const knex = require('./knex');
|
||||
|
||||
async function addAlert(alert, user) {
|
||||
console.log(alert);
|
||||
const alertId = await knex('alerts').insert({
|
||||
user_id: user.id,
|
||||
notify: alert.notify,
|
||||
email: alert.notify,
|
||||
});
|
||||
|
||||
console.log(alertId);
|
||||
}
|
||||
|
||||
async function removeAlert(alertId) {
|
||||
await knex('alerts').where('id', alertId).delete();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addAlert,
|
||||
removeAlert,
|
||||
};
|
||||
@@ -358,6 +358,7 @@ async function writeThumbnail(image, thumbpath) {
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.jpeg({ quality: config.media.thumbnailQuality })
|
||||
.rotate()
|
||||
.toFile(path.join(config.media.path, thumbpath));
|
||||
}
|
||||
|
||||
@@ -368,6 +369,7 @@ async function writeLazy(image, lazypath) {
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.jpeg({ quality: config.media.lazyQuality })
|
||||
.rotate()
|
||||
.toFile(path.join(config.media.path, lazypath));
|
||||
}
|
||||
|
||||
@@ -444,8 +446,9 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil
|
||||
},
|
||||
meta: {
|
||||
...media.meta,
|
||||
width: info.width,
|
||||
height: info.height,
|
||||
// 6 or 8 implies image is sideways, and size is not inherently adjusted for orientation
|
||||
width: info.orientation === 6 || info.orientation === 8 ? info.height : info.width,
|
||||
height: info.orientation === 6 || info.orientation === 8 ? info.width : info.height,
|
||||
entropy: stats?.entropy || null,
|
||||
sharpness: stats?.sharpness || null,
|
||||
},
|
||||
|
||||
20
src/web/alerts.js
Normal file
20
src/web/alerts.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const { addAlert, removeAlert } = require('../alerts');
|
||||
|
||||
async function addAlertApi(req, res) {
|
||||
const alert = await addAlert(req.body, req.session.user);
|
||||
|
||||
res.send(alert);
|
||||
}
|
||||
|
||||
async function removeAlertApi(req, res) {
|
||||
await removeAlert(req.params.alertId);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addAlert: addAlertApi,
|
||||
removeAlert: removeAlertApi,
|
||||
};
|
||||
@@ -55,6 +55,11 @@ const {
|
||||
updateStash,
|
||||
} = require('./stashes');
|
||||
|
||||
const {
|
||||
addAlert,
|
||||
removeAlert,
|
||||
} = require('./alerts');
|
||||
|
||||
async function initServer() {
|
||||
const app = express();
|
||||
const router = Router();
|
||||
@@ -98,6 +103,9 @@ async function initServer() {
|
||||
router.delete('/api/stashes/:stashId/scenes/:sceneId', unstashScene);
|
||||
router.delete('/api/stashes/:stashId/movies/:movieId', unstashMovie);
|
||||
|
||||
router.post('/api/alerts', addAlert);
|
||||
router.delete('/api/alerts', removeAlert);
|
||||
|
||||
router.get('/api/scenes', fetchScenes);
|
||||
router.get('/api/scenes/:releaseId', fetchScene);
|
||||
router.get('/api/scenes/:releaseId/poster', fetchScenePoster);
|
||||
|
||||
Reference in New Issue
Block a user