mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +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;
|
||||
} catch (e) {
|
||||
if (e.code === 'ap_get_410') {
|
||||
const exists = await user.exists(id);
|
||||
if (exists) {
|
||||
await user.deleteAccount(id);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -264,19 +264,26 @@ ActivityPub.get = async (type, id, uri) => {
|
||||
});
|
||||
|
||||
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')) {
|
||||
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);
|
||||
return body;
|
||||
} catch (e) {
|
||||
if (String(e.code).startsWith('ap_get_')) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 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}`);
|
||||
|
||||
if (!userData || !userData.username) {
|
||||
console.log('ERRORING', uid, userData);
|
||||
delete deletesInProgress[uid];
|
||||
throw new Error('[[error:no-user]]');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user