From 2170c40007ef8b6e756a6392ef69e88dc0e3bdfb Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 8 Dec 2020 13:07:25 -0500 Subject: [PATCH] fix: iteration logic bug --- public/openapi/write/topics/tid/thumbs.yaml | 18 ++++++++++++++++-- src/topics/thumbs.js | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/openapi/write/topics/tid/thumbs.yaml b/public/openapi/write/topics/tid/thumbs.yaml index d8c914ec01..a51858aeb3 100644 --- a/public/openapi/write/topics/tid/thumbs.yaml +++ b/public/openapi/write/topics/tid/thumbs.yaml @@ -22,8 +22,18 @@ get: status: $ref: ../../../components/schemas/Status.yaml#/Status response: - type: object - properties: {} + type: array + description: A list of the topic thumbnails that still remain + items: + type: object + properties: + id: + type: string + name: + type: string + url: + type: string + description: Path to a topic thumbnail post: tags: - topics @@ -141,6 +151,10 @@ delete: items: type: object properties: + id: + type: string + name: + type: string url: type: string description: Path to a topic thumbnail \ No newline at end of file diff --git a/src/topics/thumbs.js b/src/topics/thumbs.js index 0601f79982..4b56f454af 100644 --- a/src/topics/thumbs.js +++ b/src/topics/thumbs.js @@ -29,7 +29,7 @@ Thumbs.get = async function (tids) { const sets = tids.map(tid => `${validator.isUUID(String(tid)) ? 'draft' : 'topic'}:${tid}:thumbs`); const thumbs = await db.getSortedSetsMembers(sets); - let response = thumbs.map(thumbSet => thumbSet.map((thumb, idx) => ({ + let response = thumbs.map((thumbSet, idx) => thumbSet.map(thumb => ({ id: tids[idx], name: path.basename(thumb), url: path.join(nconf.get('upload_url'), thumb),