mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -58,8 +58,20 @@ Contexts.getItems = async (uid, id, options) => {
|
|||||||
options.root = true;
|
options.root = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
activitypub.helpers.log(`[activitypub/context] Retrieving context ${id}`);
|
// Page object instead of id
|
||||||
let { type, items, orderedItems, first, next } = await activitypub.get('uid', uid, id);
|
let object;
|
||||||
|
if (!id && options.object) {
|
||||||
|
object = options.object;
|
||||||
|
} else {
|
||||||
|
activitypub.helpers.log(`[activitypub/context] Retrieving context/page ${id}`);
|
||||||
|
try {
|
||||||
|
object = await activitypub.get('uid', uid, id);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let { type, items, orderedItems, first, next } = object;
|
||||||
|
|
||||||
if (!activitypub._constants.acceptable.contextTypes.has(type)) {
|
if (!activitypub._constants.acceptable.contextTypes.has(type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -87,14 +99,18 @@ Contexts.getItems = async (uid, id, options) => {
|
|||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
activitypub.helpers.log('[activitypub/context] Fetching next page...');
|
activitypub.helpers.log('[activitypub/context] Fetching next page...');
|
||||||
|
const isUrl = activitypub.helpers.isUri(next);
|
||||||
Array
|
Array
|
||||||
.from(await Contexts.getItems(uid, next, {
|
.from(await Contexts.getItems(uid, isUrl && next, {
|
||||||
...options,
|
...options,
|
||||||
root: false,
|
root: false,
|
||||||
|
object: !isUrl && next,
|
||||||
}))
|
}))
|
||||||
.forEach((item) => {
|
.forEach((item) => {
|
||||||
chain.add(item);
|
chain.add(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle special case where originating object is not actually part of the context collection
|
// Handle special case where originating object is not actually part of the context collection
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reorder chain items by timestamp
|
// Reorder chain items by timestamp
|
||||||
// chain = chain.sort((a, b) => a.timestamp - b.timestamp);
|
chain = chain.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
|
|
||||||
const mainPost = chain[0];
|
const mainPost = chain[0];
|
||||||
let { pid: mainPid, tid, uid: authorId, timestamp, name, content, sourceContent, _activitypub } = mainPost;
|
let { pid: mainPid, tid, uid: authorId, timestamp, name, content, sourceContent, _activitypub } = mainPost;
|
||||||
|
|||||||
Reference in New Issue
Block a user