aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorPitu <[email protected]>2017-01-19 17:14:28 -0300
committerPitu <[email protected]>2017-01-19 17:14:28 -0300
commitbb0f7465980e0245eefa663636354922c8c1c868 (patch)
tree830790c1a275e80621d41a94aadcc2d6621fde44 /controllers
parentSmall fix for listing (diff)
downloadhost.fuwn.me-bb0f7465980e0245eefa663636354922c8c1c868.tar.xz
host.fuwn.me-bb0f7465980e0245eefa663636354922c8c1c868.zip
Album delete WIP
Diffstat (limited to 'controllers')
-rw-r--r--controllers/albumsController.js15
-rw-r--r--controllers/uploadController.js1
2 files changed, 14 insertions, 2 deletions
diff --git a/controllers/albumsController.js b/controllers/albumsController.js
index 55885f5..47ab1d5 100644
--- a/controllers/albumsController.js
+++ b/controllers/albumsController.js
@@ -48,7 +48,7 @@ albumsController.create = function(req, res, next){
if(name === undefined || name === '')
return res.json({ success: false, description: 'No album name specified' })
- db.table('albums').where('name', name).then((album) => {
+ db.table('albums').where('name', name).where('enabled', 1).then((album) => {
if(album.length !== 0) return res.json({ success: false, description: 'There\'s already an album with that name' })
db.table('albums').insert({
@@ -61,5 +61,18 @@ albumsController.create = function(req, res, next){
})
}
+albumsController.delete = function(req, res, next){
+ if(req.headers.auth !== config.adminToken)
+ return res.status(401).json({ success: false, description: 'not-authorized'})
+
+ let id = req.body.id
+ if(id === undefined || id === '')
+ return res.json({ success: false, description: 'No album specified' })
+
+ db.table('albums').where('id', id).update({ enabled: 0 }).then(() => {
+ return res.json({ success: true })
+ })
+}
+
module.exports = albumsController \ No newline at end of file
diff --git a/controllers/uploadController.js b/controllers/uploadController.js
index 10ee4c7..87b3ab6 100644
--- a/controllers/uploadController.js
+++ b/controllers/uploadController.js
@@ -123,7 +123,6 @@ uploadsController.list = function(req, res){
for(let file of files){
file.file = 'http://' + basedomain + '/' + file.name
- //file.file = config.basedomain + config.uploads.prefix + file.name
file.date = new Date(file.timestamp * 1000)
file.date = file.date.getFullYear() + '-' + (file.date.getMonth() + 1) + '-' + file.date.getDate() + ' ' + (file.date.getHours() < 10 ? '0' : '') + file.date.getHours() + ':' + (file.date.getMinutes() < 10 ? '0' : '') + file.date.getMinutes() + ':' + (file.date.getSeconds() < 10 ? '0' : '') + file.date.getSeconds()