aboutsummaryrefslogtreecommitdiff
path: root/controllers/uploadController.js
diff options
context:
space:
mode:
authorPitu <[email protected]>2017-10-04 02:05:38 -0300
committerPitu <[email protected]>2017-10-04 02:05:38 -0300
commit992b632d1a0b6dc6e44daf79bbfceb09f0260770 (patch)
treec2c19afd3d22b806c95e71f0c0bb7c33f733e80c /controllers/uploadController.js
parentMissing semicolon (diff)
downloadhost.fuwn.me-992b632d1a0b6dc6e44daf79bbfceb09f0260770.tar.xz
host.fuwn.me-992b632d1a0b6dc6e44daf79bbfceb09f0260770.zip
Added album downloading through front-end
Diffstat (limited to 'controllers/uploadController.js')
-rw-r--r--controllers/uploadController.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/controllers/uploadController.js b/controllers/uploadController.js
index f0f75f6..42fccf5 100644
--- a/controllers/uploadController.js
+++ b/controllers/uploadController.js
@@ -42,7 +42,7 @@ uploadsController.upload = async (req, res, next) => {
const albumid = req.headers.albumid || req.params.albumid;
if (albumid && user) {
- const album = await db.table('albums').where({ id: album, userid: user.id }).first();
+ const album = await db.table('albums').where({ id: albumid, userid: user.id }).first();
if (!album) {
return res.json({
success: false,
@@ -150,6 +150,11 @@ uploadsController.processFilesForDisplay = async (req, res, files, existingFiles
file.thumb = `${basedomain}/thumbs/${file.name.slice(0, -ext.length)}.png`;
utils.generateThumbs(file);
}
+
+ if (file.albumid) {
+ db.table('albums').where('id', file.albumid).update('editedAt', file.timestamp).then(() => {})
+ .catch(error => { console.log(error); res.json({ success: false, description: 'Error updating album' }); });
+ }
}
};
@@ -172,6 +177,9 @@ uploadsController.delete = async (req, res) => {
try {
await uploadsController.deleteFile(file.name);
await db.table('files').where('id', id).del();
+ if (file.albumid) {
+ await db.table('albums').where('id', file.albumid).update('editedAt', Math.floor(Date.now() / 1000));
+ }
} catch (err) {
console.log(err);
}