Added alert dialog. Fixed image rotation EXIT data being discarded.

This commit is contained in:
DebaucheryLibrarian
2021-04-04 21:52:19 +02:00
parent 837fc98ad2
commit da0cbced15
43 changed files with 1134 additions and 38 deletions

23
src/alerts.js Normal file
View 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,
};

View File

@@ -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
View 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,
};

View File

@@ -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);