mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 14:27:05 +02:00
feat: #12976, shares collection
This commit is contained in:
@@ -265,6 +265,7 @@ async function getCounts(userData, callerUID) {
|
||||
const promises = {
|
||||
posts: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids`)),
|
||||
topics: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:tids`)),
|
||||
shares: db.sortedSetCard(`uid:${uid}:shares`),
|
||||
};
|
||||
if (userData.isAdmin || userData.isSelf) {
|
||||
promises.uploaded = db.sortedSetCard(`uid:${uid}:uploads`);
|
||||
|
||||
@@ -147,6 +147,14 @@ const templateToData = {
|
||||
return cids.map(c => `cid:${c}:uid:${userData.uid}:tids`);
|
||||
},
|
||||
},
|
||||
'account/shares': {
|
||||
type: 'topics',
|
||||
noItemsFoundKey: '[[user:has-no-shares]]',
|
||||
crumb: '[[user:shares]]',
|
||||
getSets: async function (callerUid, userData) {
|
||||
return `uid:${userData.uid}:shares`;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
postsController.getBookmarks = async function (req, res, next) {
|
||||
@@ -189,6 +197,10 @@ postsController.getTopics = async function (req, res, next) {
|
||||
await getPostsFromUserSet('account/topics', req, res, next);
|
||||
};
|
||||
|
||||
postsController.getShares = async function (req, res, next) {
|
||||
await getPostsFromUserSet('account/shares', req, res, next);
|
||||
};
|
||||
|
||||
async function getPostsFromUserSet(template, req, res) {
|
||||
const data = templateToData[template];
|
||||
const page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
||||
|
||||
Reference in New Issue
Block a user