mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: activitypub.get failure handling
This commit is contained in:
@@ -29,8 +29,9 @@ Notes.assert = async (uid, input, options = {}) => {
|
|||||||
|
|
||||||
if (!exists || options.update === true) {
|
if (!exists || options.update === true) {
|
||||||
let postData;
|
let postData;
|
||||||
winston.verbose(`[activitypub/notes.assert] Not found, saving note to database`);
|
winston.verbose(`[activitypub/notes.assert] Not found, retrieving note for persistence...`);
|
||||||
if (activitypub.helpers.isUri(item)) {
|
if (activitypub.helpers.isUri(item)) {
|
||||||
|
// get failure throws for now but should save intermediate object
|
||||||
const object = await activitypub.get('uid', uid, item);
|
const object = await activitypub.get('uid', uid, item);
|
||||||
postData = await activitypub.mocks.post(object);
|
postData = await activitypub.mocks.post(object);
|
||||||
} else {
|
} else {
|
||||||
@@ -38,6 +39,7 @@ Notes.assert = async (uid, input, options = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await db.setObject(key, postData);
|
await db.setObject(key, postData);
|
||||||
|
winston.verbose(`[activitypub/notes.assert] Note ${id} saved.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.update === true) {
|
if (options.update === true) {
|
||||||
@@ -67,7 +69,12 @@ Notes.getParentChain = async (uid, input) => {
|
|||||||
await traverse(uid, postData.toPid);
|
await traverse(uid, postData.toPid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let object = await activitypub.get('uid', uid, id);
|
let object;
|
||||||
|
try {
|
||||||
|
object = await activitypub.get('uid', uid, id);
|
||||||
|
} catch (e) {
|
||||||
|
winston.warn(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle incorrect id passed in
|
// Handle incorrect id passed in
|
||||||
if (id !== object.id) {
|
if (id !== object.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user