Node.js based forum software built for the modern web
fix: #12893, topic with pages returning OrderedCollectionPage instead of OrderedCollection.
Julian Lamd685b20e0aa1
diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex 6f597ee772..5165a9c166 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -429,7 +429,7 @@ Helpers.generateCollection = async ({ set, method, page, perPage, url }) => {}const object = {- type: paginate && items ? 'OrderedCollectionPage' : 'OrderedCollection',+ type: paginate && items.length ? 'OrderedCollectionPage' : 'OrderedCollection',totalItems: count,};diff --git a/src/controllers/activitypub/actors.js b/src/controllers/activitypub/actors.jsindex b477069927..c80f6e2867 100644--- a/src/controllers/activitypub/actors.js+++ b/src/controllers/activitypub/actors.js@@ -118,7 +118,7 @@ Actors.topic = async function (req, res, next) {return res.sendStatus(404);}- const page = parseInt(req.query.page, 10);+ const page = parseInt(req.query.page, 10) || undefined;const perPage = meta.config.postsPerPage;const { cid, titleRaw: name, mainPid, slug } = await topics.getTopicFields(req.params.tid, ['cid', 'title', 'mainPid', 'slug']);try {@@ -132,10 +132,11 @@ Actors.topic = async function (req, res, next) {}),db.getSortedSetMembers(`tid:${req.params.tid}:posts`),]);-- // Generate digest for ETagpids.push(mainPid);pids = pids.map(pid => (utils.isNumber(pid) ? `${nconf.get('url')}/post/${pid}` : pid));+ collection.totalItems += 1; // account for mainPid++ // Generate digest for ETagconst digest = activitypub.helpers.generateDigest(new Set(pids));const ifNoneMatch = (req.get('If-None-Match') || '').split(',').map((tag) => {tag = tag.trim();@@ -151,7 +152,6 @@ Actors.topic = async function (req, res, next) {res.set('ETag', digest);// Convert pids to urls- collection.totalItems += 1;if (page || collection.totalItems < meta.config.postsPerPage) {collection.orderedItems = collection.orderedItems || [];if (!page || page === 1) { // add OP to collection