feat: add read topics route

remove counts that were no longer displayed
up themes
This commit is contained in:
Barış Soner Uşaklı
2024-10-09 19:13:25 -04:00
parent 5159552deb
commit 757d710115
10 changed files with 81 additions and 23 deletions

View File

@@ -107,10 +107,10 @@
"nodebb-plugin-ntfy": "1.7.7", "nodebb-plugin-ntfy": "1.7.7",
"nodebb-plugin-spam-be-gone": "2.2.2", "nodebb-plugin-spam-be-gone": "2.2.2",
"nodebb-rewards-essentials": "1.0.0", "nodebb-rewards-essentials": "1.0.0",
"nodebb-theme-harmony": "1.2.72", "nodebb-theme-harmony": "1.2.73",
"nodebb-theme-lavender": "7.1.8", "nodebb-theme-lavender": "7.1.8",
"nodebb-theme-peace": "2.2.7", "nodebb-theme-peace": "2.2.7",
"nodebb-theme-persona": "13.3.37", "nodebb-theme-persona": "13.3.38",
"nodebb-widget-essentials": "7.0.29", "nodebb-widget-essentials": "7.0.29",
"nodemailer": "6.9.15", "nodemailer": "6.9.15",
"nprogress": "0.2.0", "nprogress": "0.2.0",

View File

@@ -60,6 +60,7 @@
"account/settings-of": "Changing settings of %1", "account/settings-of": "Changing settings of %1",
"account/watched": "Topics watched by %1", "account/watched": "Topics watched by %1",
"account/ignored": "Topics ignored by %1", "account/ignored": "Topics ignored by %1",
"account/read": "Topics read by %1",
"account/upvoted": "Posts upvoted by %1", "account/upvoted": "Posts upvoted by %1",
"account/downvoted": "Posts downvoted by %1", "account/downvoted": "Posts downvoted by %1",
"account/best": "Best posts made by %1", "account/best": "Best posts made by %1",

View File

@@ -45,6 +45,7 @@
"change-all": "Change All", "change-all": "Change All",
"watched": "Watched", "watched": "Watched",
"ignored": "Ignored", "ignored": "Ignored",
"read": "Read",
"default-category-watch-state": "Default category watch state", "default-category-watch-state": "Default category watch state",
"followers": "Followers", "followers": "Followers",
"following": "Following", "following": "Following",
@@ -121,6 +122,7 @@
"has-no-topics": "This user hasn't posted any topics yet.", "has-no-topics": "This user hasn't posted any topics yet.",
"has-no-watched-topics": "This user hasn't watched any topics yet.", "has-no-watched-topics": "This user hasn't watched any topics yet.",
"has-no-ignored-topics": "This user hasn't ignored any topics yet.", "has-no-ignored-topics": "This user hasn't ignored any topics yet.",
"has-no-read-topics": "This user hasn't read any topics yet.",
"has-no-upvoted-posts": "This user hasn't upvoted any posts yet.", "has-no-upvoted-posts": "This user hasn't upvoted any posts yet.",
"has-no-downvoted-posts": "This user hasn't downvoted any posts yet.", "has-no-downvoted-posts": "This user hasn't downvoted any posts yet.",
"has-no-controversial-posts": "This user does not have any downvoted posts yet.", "has-no-controversial-posts": "This user does not have any downvoted posts yet.",

View File

@@ -387,38 +387,24 @@ UserObjectFull:
counts: counts:
type: object type: object
properties: properties:
best:
type: number
controversial:
type: number
blocks: blocks:
type: number type: number
bookmarks:
type: number
categoriesWatched: categoriesWatched:
type: number type: number
tagsWatched: tagsWatched:
type: number type: number
downvoted:
type: number
followers: followers:
type: number type: number
following: following:
type: number type: number
groups: groups:
type: number type: number
ignored:
type: number
posts: posts:
type: number type: number
topics: topics:
type: number type: number
uploaded: uploaded:
type: number type: number
upvoted:
type: number
watched:
type: number
isBlocked: isBlocked:
type: boolean type: boolean
blocksCount: blocksCount:

View File

@@ -282,6 +282,8 @@ paths:
$ref: 'read/user/userslug/watched.yaml' $ref: 'read/user/userslug/watched.yaml'
"/api/user/{userslug}/ignored": "/api/user/{userslug}/ignored":
$ref: 'read/user/userslug/ignored.yaml' $ref: 'read/user/userslug/ignored.yaml'
"/api/user/{userslug}/read":
$ref: 'read/user/userslug/read.yaml'
"/api/user/{userslug}/upvoted": "/api/user/{userslug}/upvoted":
$ref: 'read/user/userslug/upvoted.yaml' $ref: 'read/user/userslug/upvoted.yaml'
"/api/user/{userslug}/downvoted": "/api/user/{userslug}/downvoted":

View File

@@ -0,0 +1,47 @@
get:
tags:
- users
summary: Get a user's read topics
parameters:
- name: userslug
in: path
required: true
schema:
type: string
example: admin
responses:
"200":
description: ""
content:
application/json:
schema:
allOf:
- $ref: ../../../components/schemas/UserObject.yaml#/UserObjectFull
- type: object
properties:
topics:
type: array
items:
$ref: ../../../components/schemas/TopicObject.yaml#/TopicObject
nextStart:
type: number
noItemsFoundKey:
type: string
title:
type: string
showSort:
type: boolean
sortOptions:
type: array
items:
type: object
properties:
url:
type: string
name:
type: string
selected:
type: boolean
- $ref: ../../../components/schemas/Pagination.yaml#/Pagination
- $ref: ../../../components/schemas/Breadcrumbs.yaml#/Breadcrumbs
- $ref: ../../../components/schemas/CommonProps.yaml#/CommonProps

View File

@@ -0,0 +1,14 @@
'use strict';
define('forum/account/read', ['forum/account/header', 'forum/account/topics'], function (header, topics) {
const AccountRead = {};
AccountRead.init = function () {
header.init();
topics.handleInfiniteScroll('account/read');
};
return AccountRead;
});

View File

@@ -184,16 +184,9 @@ async function getCounts(userData, callerUID) {
const cids = await categories.getCidsByPrivilege('categories:cid', callerUID, 'topics:read'); const cids = await categories.getCidsByPrivilege('categories:cid', callerUID, 'topics:read');
const promises = { const promises = {
posts: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids`)), posts: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids`)),
best: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids:votes`), 1, '+inf'),
controversial: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids:votes`), '-inf', -1),
topics: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:tids`)), topics: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:tids`)),
}; };
if (userData.isAdmin || userData.isSelf) { if (userData.isAdmin || userData.isSelf) {
promises.ignored = db.sortedSetCard(`uid:${uid}:ignored_tids`);
promises.watched = db.sortedSetCard(`uid:${uid}:followed_tids`);
promises.upvoted = db.sortedSetCard(`uid:${uid}:upvote`);
promises.downvoted = db.sortedSetCard(`uid:${uid}:downvote`);
promises.bookmarks = db.sortedSetCard(`uid:${uid}:bookmarks`);
promises.uploaded = db.sortedSetCard(`uid:${uid}:uploads`); promises.uploaded = db.sortedSetCard(`uid:${uid}:uploads`);
promises.categoriesWatched = user.getWatchedCategories(uid); promises.categoriesWatched = user.getWatchedCategories(uid);
promises.tagsWatched = db.sortedSetCard(`uid:${uid}:followed_tags`); promises.tagsWatched = db.sortedSetCard(`uid:${uid}:followed_tags`);

View File

@@ -126,6 +126,14 @@ const templateToData = {
return `uid:${userData.uid}:ignored_tids`; return `uid:${userData.uid}:ignored_tids`;
}, },
}, },
'account/read': {
type: 'topics',
noItemsFoundKey: '[[user:has-no-read-topics]]',
crumb: '[[user:read]]',
getSets: function (callerUid, userData) {
return `uid:${userData.uid}:tids_read`;
},
},
'account/topics': { 'account/topics': {
type: 'topics', type: 'topics',
noItemsFoundKey: '[[user:has-no-topics]]', noItemsFoundKey: '[[user:has-no-topics]]',
@@ -169,6 +177,10 @@ postsController.getIgnoredTopics = async function (req, res, next) {
await getPostsFromUserSet('account/ignored', req, res, next); await getPostsFromUserSet('account/ignored', req, res, next);
}; };
postsController.getReadTopics = async function (req, res, next) {
await getPostsFromUserSet('account/read', req, res, next);
};
postsController.getTopics = async function (req, res, next) { postsController.getTopics = async function (req, res, next) {
await getPostsFromUserSet('account/topics', req, res, next); await getPostsFromUserSet('account/topics', req, res, next);
}; };

View File

@@ -35,6 +35,7 @@ module.exports = function (app, name, middleware, controllers) {
setupPageRoute(app, `/${name}/:userslug/bookmarks`, accountMiddlewares, controllers.accounts.posts.getBookmarks); setupPageRoute(app, `/${name}/:userslug/bookmarks`, accountMiddlewares, controllers.accounts.posts.getBookmarks);
setupPageRoute(app, `/${name}/:userslug/watched`, accountMiddlewares, controllers.accounts.posts.getWatchedTopics); setupPageRoute(app, `/${name}/:userslug/watched`, accountMiddlewares, controllers.accounts.posts.getWatchedTopics);
setupPageRoute(app, `/${name}/:userslug/ignored`, accountMiddlewares, controllers.accounts.posts.getIgnoredTopics); setupPageRoute(app, `/${name}/:userslug/ignored`, accountMiddlewares, controllers.accounts.posts.getIgnoredTopics);
setupPageRoute(app, `/${name}/:userslug/read`, accountMiddlewares, controllers.accounts.posts.getReadTopics);
setupPageRoute(app, `/${name}/:userslug/upvoted`, accountMiddlewares, controllers.accounts.posts.getUpVotedPosts); setupPageRoute(app, `/${name}/:userslug/upvoted`, accountMiddlewares, controllers.accounts.posts.getUpVotedPosts);
setupPageRoute(app, `/${name}/:userslug/downvoted`, accountMiddlewares, controllers.accounts.posts.getDownVotedPosts); setupPageRoute(app, `/${name}/:userslug/downvoted`, accountMiddlewares, controllers.accounts.posts.getDownVotedPosts);
setupPageRoute(app, `/${name}/:userslug/edit`, accountMiddlewares, controllers.accounts.edit.get); setupPageRoute(app, `/${name}/:userslug/edit`, accountMiddlewares, controllers.accounts.edit.get);