mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
feat: send cause to ap.get error handler, delete local account representation if assertion fails with a 410
This commit is contained in:
@@ -122,6 +122,13 @@ Actors.assert = async (ids, options = {}) => {
|
|||||||
|
|
||||||
return actor;
|
return actor;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (e.code === 'ap_get_410') {
|
||||||
|
const exists = await user.exists(id);
|
||||||
|
if (exists) {
|
||||||
|
await user.deleteAccount(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -264,19 +264,26 @@ ActivityPub.get = async (type, id, uri) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!String(response.statusCode).startsWith('2')) {
|
if (!String(response.statusCode).startsWith('2')) {
|
||||||
winston.error(`[activitypub/get] Received ${response.statusCode} when querying ${uri}`);
|
winston.verbose(`[activitypub/get] Received ${response.statusCode} when querying ${uri}`);
|
||||||
if (body.hasOwnProperty('error')) {
|
if (body.hasOwnProperty('error')) {
|
||||||
winston.error(`[activitypub/get] Error received: ${body.error}`);
|
winston.verbose(`[activitypub/get] Error received: ${body.error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`[[error:activitypub.get-failed]]`);
|
const e = new Error(`[[error:activitypub.get-failed]]`);
|
||||||
|
e.code = `ap_get_${response.statusCode}`;
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCache.set(cacheKey, body);
|
requestCache.set(cacheKey, body);
|
||||||
return body;
|
return body;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (String(e.code).startsWith('ap_get_')) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle things like non-json body, etc.
|
// Handle things like non-json body, etc.
|
||||||
throw new Error(`[[error:activitypub.get-failed]]`);
|
const { cause } = e;
|
||||||
|
throw new Error(`[[error:activitypub.get-failed]]`, { cause });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ module.exports = function (User) {
|
|||||||
const userData = await db.getObject(utils.isNumber(uid) ? `user:${uid}` : `userRemote:${uid}`);
|
const userData = await db.getObject(utils.isNumber(uid) ? `user:${uid}` : `userRemote:${uid}`);
|
||||||
|
|
||||||
if (!userData || !userData.username) {
|
if (!userData || !userData.username) {
|
||||||
console.log('ERRORING', uid, userData);
|
|
||||||
delete deletesInProgress[uid];
|
delete deletesInProgress[uid];
|
||||||
throw new Error('[[error:no-user]]');
|
throw new Error('[[error:no-user]]');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user