diff options
| author | Pitu <[email protected]> | 2018-09-17 04:38:25 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-17 04:38:25 -0300 |
| commit | c2c6e99878853fafdbd5e708c3163921f8529ae1 (patch) | |
| tree | 8313268655c19bc74497172ee1d0642a52e93984 /src/api/routes/albums/link/linkPOST.js | |
| parent | This route should handle more stuff, so it does now (diff) | |
| download | host.fuwn.me-c2c6e99878853fafdbd5e708c3163921f8529ae1.tar.xz host.fuwn.me-c2c6e99878853fafdbd5e708c3163921f8529ae1.zip | |
Public albums wooo!
Diffstat (limited to 'src/api/routes/albums/link/linkPOST.js')
| -rw-r--r-- | src/api/routes/albums/link/linkPOST.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/api/routes/albums/link/linkPOST.js b/src/api/routes/albums/link/linkPOST.js index 26a527a..9c8c0bc 100644 --- a/src/api/routes/albums/link/linkPOST.js +++ b/src/api/routes/albums/link/linkPOST.js @@ -17,6 +17,9 @@ class linkPOST extends Route { const exists = await db.table('albums').where('id', albumId).first(); if (!exists) return res.status(400).json({ message: 'Album doesn\t exist' }); + const count = await db.table('links').where('albumId', albumId).count({ count: 'id' }); + if (count[0].count >= config.albums.maxLinksPerAlbum) return res.status(400).json({ message: 'Maximum links per album reached' }); + const identifier = await Util.getUniqueAlbumIdentifier(); if (!identifier) return res.status(500).json({ message: 'There was a problem allocating a link for your album' }); |