From b18e7e319ba0f36200eeeda308704591840cb82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 23 Nov 2020 14:18:47 -0500 Subject: [PATCH] fix: spec --- .../components/schemas/UserObject.yaml | 31 +++++++++++++++++++ .../openapi/read/user/userslug/watched.yaml | 31 +++++++++++++++++++ src/controllers/accounts/blocks.js | 2 +- src/controllers/accounts/helpers.js | 1 + 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/public/openapi/components/schemas/UserObject.yaml b/public/openapi/components/schemas/UserObject.yaml index 1970b7a23e..2edc402156 100644 --- a/public/openapi/components/schemas/UserObject.yaml +++ b/public/openapi/components/schemas/UserObject.yaml @@ -355,6 +355,37 @@ UserObjectFull: type: string moderationNote: type: string + counts: + type: object + properties: + best: + type: number + blocks: + type: number + bookmarks: + type: number + categoriesWatched: + type: number + downvoted: + type: number + followers: + type: number + following: + type: number + groups: + type: number + ignored: + type: number + posts: + type: number + topics: + type: number + uploaded: + type: number + upvoted: + type: number + watched: + type: number isBlocked: type: boolean blocksCount: diff --git a/public/openapi/read/user/userslug/watched.yaml b/public/openapi/read/user/userslug/watched.yaml index baa79b19e9..9069465791 100644 --- a/public/openapi/read/user/userslug/watched.yaml +++ b/public/openapi/read/user/userslug/watched.yaml @@ -29,6 +29,37 @@ get: type: array items: type: string + counts: + type: object + properties: + best: + type: number + blocks: + type: number + bookmarks: + type: number + categoriesWatched: + type: number + downvoted: + type: number + followers: + type: number + following: + type: number + groups: + type: number + ignored: + type: number + posts: + type: number + topics: + type: number + uploaded: + type: number + upvoted: + type: number + watched: + type: number isBlocked: type: boolean blocksCount: diff --git a/src/controllers/accounts/blocks.js b/src/controllers/accounts/blocks.js index cc9101e788..fac52e8227 100644 --- a/src/controllers/accounts/blocks.js +++ b/src/controllers/accounts/blocks.js @@ -30,7 +30,7 @@ blocksController.getBlocks = async function (req, res, next) { userData.users = await user.getUsers(data.uids, req.uid); userData.title = '[[pages:account/blocks, ' + userData.username + ']]'; - const pageCount = Math.ceil(userData.blocksCount / resultsPerPage); + const pageCount = Math.ceil(userData.counts.blocks / resultsPerPage); userData.pagination = pagination.create(page, pageCount); userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:blocks]]' }]); diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index 1d1d8110ca..ed07c2a6f9 100644 --- a/src/controllers/accounts/helpers.js +++ b/src/controllers/accounts/helpers.js @@ -161,6 +161,7 @@ async function getCounts(userData, callerUID) { counts.groups = userData.groups.length; counts.following = userData.followingCount; counts.followers = userData.followerCount; + userData.blocksCount = counts.blocks || 0; // for backwards compatibility, remove in 1.16.0 userData.counts = counts; }