mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
feat: flesh out more topic info, fix navigator
This commit is contained in:
@@ -176,6 +176,7 @@ ActivityPub.get = async (uid, uri) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const headers = uid > 0 ? await ActivityPub.sign(uid, uri) : {};
|
const headers = uid > 0 ? await ActivityPub.sign(uid, uri) : {};
|
||||||
|
winston.verbose(`[activitypub/get] ${uri}`);
|
||||||
const { response, body } = await request.get(uri, {
|
const { response, body } = await request.get(uri, {
|
||||||
headers: {
|
headers: {
|
||||||
...headers,
|
...headers,
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ Notes.assertTopic = async (uid, id) => {
|
|||||||
sorted.map(n => n.timestamp),
|
sorted.map(n => n.timestamp),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const postercount = chain.reduce((set, cur) => {
|
||||||
|
set.add(cur.uid);
|
||||||
|
return set;
|
||||||
|
}, new Set());
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.setObject(`topicRemote:${tid}`, {
|
db.setObject(`topicRemote:${tid}`, {
|
||||||
tid,
|
tid,
|
||||||
@@ -79,6 +84,7 @@ Notes.assertTopic = async (uid, id) => {
|
|||||||
title: 'TBD',
|
title: 'TBD',
|
||||||
slug: `remote?resource=${encodeURIComponent(tid)}`,
|
slug: `remote?resource=${encodeURIComponent(tid)}`,
|
||||||
postcount: sorted.length,
|
postcount: sorted.length,
|
||||||
|
postercount,
|
||||||
}),
|
}),
|
||||||
db.sortedSetAdd(`tidRemote:${tid}:posts`, timestamps, ids),
|
db.sortedSetAdd(`tidRemote:${tid}:posts`, timestamps, ids),
|
||||||
Notes.assert(uid, chain),
|
Notes.assert(uid, chain),
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
const topics = require('../../topics');
|
const topics = require('../../topics');
|
||||||
|
|
||||||
const { notes } = require('../../activitypub');
|
const { notes } = require('../../activitypub');
|
||||||
// const helpers = require('../helpers');
|
// const helpers = require('../helpers');
|
||||||
// const pagination = require('../../pagination');
|
const pagination = require('../../pagination');
|
||||||
|
|
||||||
const controller = module.exports;
|
const controller = module.exports;
|
||||||
|
|
||||||
controller.get = async function (req, res, next) {
|
controller.get = async function (req, res, next) {
|
||||||
const tid = await notes.assertTopic(req.uid, req.query.resource);
|
const tid = await notes.assertTopic(req.uid, req.query.resource);
|
||||||
|
|
||||||
let postIndex = parseInt(req.params.post_index, 10) || 1;
|
let postIndex = await db.sortedSetRank(`tidRemote:${tid}:posts`, req.query.resource);
|
||||||
const [
|
const [
|
||||||
// userPrivileges,
|
// userPrivileges,
|
||||||
settings,
|
settings,
|
||||||
@@ -51,8 +54,18 @@ controller.get = async function (req, res, next) {
|
|||||||
const { start, stop } = calculateStartStop(currentPage, postIndex, settings);
|
const { start, stop } = calculateStartStop(currentPage, postIndex, settings);
|
||||||
|
|
||||||
topicData.posts = await notes.getTopicPosts(tid, req.uid, start, stop);
|
topicData.posts = await notes.getTopicPosts(tid, req.uid, start, stop);
|
||||||
|
await topics.calculatePostIndices(topicData.posts, start - 1);
|
||||||
topicData.posts = await topics.addPostData(topicData.posts, req.uid);
|
topicData.posts = await topics.addPostData(topicData.posts, req.uid);
|
||||||
|
|
||||||
|
await topics.increaseViewCount(req, tid);
|
||||||
|
|
||||||
|
topicData.postIndex = postIndex;
|
||||||
|
topicData.pagination = pagination.create(currentPage, pageCount, req.query);
|
||||||
|
topicData.pagination.rel.forEach((rel) => {
|
||||||
|
rel.href = `${nconf.get('url')}/topic/${topicData.slug}${rel.href}`;
|
||||||
|
res.locals.linkTags.push(rel);
|
||||||
|
});
|
||||||
|
|
||||||
res.render('topic', topicData);
|
res.render('topic', topicData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user