mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +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) : {};
|
||||
winston.verbose(`[activitypub/get] ${uri}`);
|
||||
const { response, body } = await request.get(uri, {
|
||||
headers: {
|
||||
...headers,
|
||||
|
||||
@@ -70,6 +70,11 @@ Notes.assertTopic = async (uid, id) => {
|
||||
sorted.map(n => n.timestamp),
|
||||
];
|
||||
|
||||
const postercount = chain.reduce((set, cur) => {
|
||||
set.add(cur.uid);
|
||||
return set;
|
||||
}, new Set());
|
||||
|
||||
await Promise.all([
|
||||
db.setObject(`topicRemote:${tid}`, {
|
||||
tid,
|
||||
@@ -79,6 +84,7 @@ Notes.assertTopic = async (uid, id) => {
|
||||
title: 'TBD',
|
||||
slug: `remote?resource=${encodeURIComponent(tid)}`,
|
||||
postcount: sorted.length,
|
||||
postercount,
|
||||
}),
|
||||
db.sortedSetAdd(`tidRemote:${tid}:posts`, timestamps, ids),
|
||||
Notes.assert(uid, chain),
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const nconf = require('nconf');
|
||||
|
||||
const db = require('../../database');
|
||||
const user = require('../../user');
|
||||
const topics = require('../../topics');
|
||||
|
||||
const { notes } = require('../../activitypub');
|
||||
// const helpers = require('../helpers');
|
||||
// const pagination = require('../../pagination');
|
||||
const pagination = require('../../pagination');
|
||||
|
||||
const controller = module.exports;
|
||||
|
||||
controller.get = async function (req, res, next) {
|
||||
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 [
|
||||
// userPrivileges,
|
||||
settings,
|
||||
@@ -51,8 +54,18 @@ controller.get = async function (req, res, next) {
|
||||
const { start, stop } = calculateStartStop(currentPage, postIndex, settings);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user