aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/albums/albumGET.js
diff options
context:
space:
mode:
authorPitu <[email protected]>2018-09-17 04:38:25 -0300
committerPitu <[email protected]>2018-09-17 04:38:25 -0300
commitc2c6e99878853fafdbd5e708c3163921f8529ae1 (patch)
tree8313268655c19bc74497172ee1d0642a52e93984 /src/api/routes/albums/albumGET.js
parentThis route should handle more stuff, so it does now (diff)
downloadhost.fuwn.me-c2c6e99878853fafdbd5e708c3163921f8529ae1.tar.xz
host.fuwn.me-c2c6e99878853fafdbd5e708c3163921f8529ae1.zip
Public albums wooo!
Diffstat (limited to 'src/api/routes/albums/albumGET.js')
-rw-r--r--src/api/routes/albums/albumGET.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/api/routes/albums/albumGET.js b/src/api/routes/albums/albumGET.js
index f9e5208..655db13 100644
--- a/src/api/routes/albums/albumGET.js
+++ b/src/api/routes/albums/albumGET.js
@@ -1,6 +1,7 @@
const Route = require('../../structures/Route');
const config = require('../../../../config');
const db = require('knex')(config.server.database);
+const Util = require('../../utils/Util');
class albumGET extends Route {
constructor() {
@@ -21,13 +22,19 @@ class albumGET extends Route {
if (!album) return res.status(400).json({ message: 'Album not found' });
const fileList = await db.table('albumsFiles').where('albumId', link.albumId);
- const fileIds = fileList.filter(el => el.file.fileId);
+ const fileIds = fileList.map(el => el.fileId);
const files = await db.table('files')
- .where('id', fileIds)
+ .whereIn('id', fileIds)
+ .orderBy('id', 'desc')
.select('name');
+ for (let file of files) {
+ file = Util.constructFilePublicLink(file);
+ }
return res.json({
message: 'Successfully retrieved files',
+ name: album.name,
+ downloadEnabled: link.enableDownload,
files
});
}