mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: AP note replies collection, closes #12675
This commit is contained in:
@@ -403,7 +403,7 @@ Mocks.note = async (post) => {
|
||||
source,
|
||||
tag,
|
||||
attachment,
|
||||
// replies: {} todo...
|
||||
replies: `${id}/replies`,
|
||||
};
|
||||
|
||||
return object;
|
||||
|
||||
@@ -62,6 +62,28 @@ Actors.note = async function (req, res) {
|
||||
res.status(200).json(payload);
|
||||
};
|
||||
|
||||
Actors.replies = async function (req, res) {
|
||||
const page = parseInt(req.query.page, 10);
|
||||
const replies = await activitypub.helpers.generateCollection({
|
||||
set: `pid:${req.params.pid}:replies`,
|
||||
page,
|
||||
perPage: meta.config.postsPerPage,
|
||||
url: `${nconf.get('url')}/post/${req.params.pid}/replies`,
|
||||
});
|
||||
|
||||
const object = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: `${nconf.get('url')}/post/${req.params.pid}/replies${replies.orderedItems && page ? `?page=${page}` : ''}`,
|
||||
url: `${nconf.get('url')}/post/${req.params.pid}`,
|
||||
...replies,
|
||||
}
|
||||
|
||||
// Convert pids to urls
|
||||
replies.orderedItems = replies.orderedItems.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid));
|
||||
|
||||
res.status(200).json(object);
|
||||
};
|
||||
|
||||
Actors.topic = async function (req, res, next) {
|
||||
const allowed = await privileges.topics.can('topics:read', req.params.tid, activitypub._constants.uid);
|
||||
if (!allowed) {
|
||||
|
||||
@@ -35,6 +35,7 @@ module.exports = function (app, middleware, controllers) {
|
||||
app.get('/uid/:uid/followers', [...middlewares, middleware.assert.user], controllers.activitypub.getFollowers);
|
||||
|
||||
app.get('/post/:pid', [...middlewares, middleware.assert.post], controllers.activitypub.actors.note);
|
||||
app.get('/post/:pid/replies', [...middlewares, middleware.assert.post], controllers.activitypub.actors.replies);
|
||||
|
||||
app.get('/topic/:tid/:slug?', [...middlewares, middleware.assert.topic], controllers.activitypub.actors.topic);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user