mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 11:11:04 +01:00
fix: reply expansion
This commit is contained in:
@@ -14,7 +14,7 @@ define('forum/topic/replies', ['forum/topic/posts', 'hooks', 'alerts', 'api'], f
|
||||
if (open.is(':not(.hidden)') && loading.is('.hidden')) {
|
||||
open.addClass('hidden');
|
||||
loading.removeClass('hidden');
|
||||
api.get(`/posts/${pid}/replies`, {}, function (err, { replies }) {
|
||||
api.get(`/posts/${encodeURIComponent(pid)}/replies`, {}, function (err, { replies }) {
|
||||
const postData = replies;
|
||||
loading.addClass('hidden');
|
||||
if (err) {
|
||||
|
||||
@@ -12,6 +12,7 @@ const plugins = require('../plugins');
|
||||
const meta = require('../meta');
|
||||
const events = require('../events');
|
||||
const privileges = require('../privileges');
|
||||
const activitypub = require('../activitypub');
|
||||
const apiHelpers = require('./helpers');
|
||||
const websockets = require('../socket.io');
|
||||
const socketHelpers = require('../socket.io/helpers');
|
||||
@@ -390,7 +391,7 @@ postsAPI.deleteDiff = async (caller, { pid, timestamp }) => {
|
||||
};
|
||||
|
||||
postsAPI.getReplies = async (caller, { pid }) => {
|
||||
if (!utils.isNumber(pid)) {
|
||||
if (!utils.isNumber(pid) && !activitypub.helpers.isUri(pid)) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const { uid } = caller;
|
||||
|
||||
@@ -5,6 +5,7 @@ const nconf = require('nconf');
|
||||
const db = require('../../database');
|
||||
const user = require('../../user');
|
||||
const topics = require('../../topics');
|
||||
const privileges = require('../../privileges');
|
||||
|
||||
const { notes } = require('../../activitypub');
|
||||
// const helpers = require('../helpers');
|
||||
@@ -23,11 +24,11 @@ controller.get = async function (req, res, next) {
|
||||
|
||||
let postIndex = await db.sortedSetRank(`tidRemote:${tid}:posts`, req.query.resource);
|
||||
const [
|
||||
// userPrivileges,
|
||||
userPrivileges,
|
||||
settings,
|
||||
// topicData,
|
||||
] = await Promise.all([
|
||||
// privileges.topics.get(tid, req.uid),
|
||||
privileges.topics.get(tid, req.uid),
|
||||
user.getSettings(req.uid),
|
||||
// topics.getTopicData(tid),
|
||||
]);
|
||||
@@ -40,7 +41,7 @@ controller.get = async function (req, res, next) {
|
||||
const invalidPagination = (settings.usePagination && (currentPage < 1 || currentPage > pageCount));
|
||||
if (
|
||||
!topicData ||
|
||||
// userPrivileges.disabled ||
|
||||
userPrivileges.disabled ||
|
||||
invalidPagination// ||
|
||||
// (topicData.scheduled && !userPrivileges.view_scheduled)
|
||||
) {
|
||||
@@ -62,6 +63,7 @@ controller.get = async function (req, res, next) {
|
||||
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.privileges = userPrivileges;
|
||||
|
||||
await topics.increaseViewCount(req, tid);
|
||||
|
||||
|
||||
@@ -6,10 +6,15 @@ const _ = require('lodash');
|
||||
|
||||
const db = require('../database');
|
||||
const topics = require('../topics');
|
||||
const activitypub = require('../activitypub');
|
||||
|
||||
module.exports = function (Posts) {
|
||||
Posts.getCidByPid = async function (pid) {
|
||||
const tid = await Posts.getPostField(pid, 'tid');
|
||||
if (!tid && activitypub.helpers.isUri(pid)) {
|
||||
return -1; // fediverse pseudo-category
|
||||
}
|
||||
|
||||
return await topics.getTopicField(tid, 'cid');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user