fix: save modified actor back to req.body

This commit is contained in:
Julian Lam
2024-04-12 11:08:31 -04:00
parent 4d07ca4c6a
commit c3365908b8

View File

@@ -48,14 +48,16 @@ middleware.validate = async function (req, res, next) {
}
winston.verbose('[middleware/activitypub] Request body check passed.');
const { actor, object } = req.body;
let { actor, object } = req.body;
// Actor normalization
if (typeof actor === 'object' && actor.hasOwnProperty('id')) {
req.body.actor = actor.id;
actor = actor.id;
req.body.actor = actor;
}
if (Array.isArray(actor)) {
req.body.actor = actor.map(a => (typeof a === 'string' ? a : a.id));
actor = actor.map(a => (typeof a === 'string' ? a : a.id));
req.body.actor = actor;
}
// Origin checking