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