From c3d91e89a806f915853236d4fd066ce8394185e6 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Mon, 6 Sep 2021 16:12:51 -0600 Subject: [PATCH] Get downloads now supports filtering by uids --- backend/app.js | 8 ++++++-- src/app/posts.services.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/app.js b/backend/app.js index 2d16fb2..fc90c23 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1763,9 +1763,13 @@ app.get('/api/thumbnail/:path', optionalJwt, async (req, res) => { // Downloads management -app.get('/api/downloads', optionalJwt, async (req, res) => { +app.post('/api/downloads', optionalJwt, async (req, res) => { const user_uid = req.isAuthenticated() ? req.user.uid : null; - const downloads = await db_api.getRecords('download_queue', {user_uid: user_uid}); + const uids = req.body.uids; + let downloads = await db_api.getRecords('download_queue', {user_uid: user_uid}); + + if (uids) downloads = downloads.filter(download => uids.includes(download['uid'])); + res.send({downloads: downloads}); }); diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 7b4aa19..e978a15 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -413,8 +413,8 @@ export class PostsService implements CanActivate { return this.http.post(this.path + 'getSubscriptions', {}, this.httpOptions); } - getCurrentDownloads() { - return this.http.get(this.path + 'downloads', this.httpOptions); + getCurrentDownloads(uids = null) { + return this.http.post(this.path + 'downloads', {uids: uids}, this.httpOptions); } getCurrentDownload(download_uid) {