feat: activitypub actor endpoint for user accounts

This commit is contained in:
Julian Lam
2023-05-17 13:13:30 -04:00
parent 51d8f3b195
commit 2dec357aee
8 changed files with 122 additions and 1 deletions

View File

@@ -297,3 +297,27 @@ middleware.handleMultipart = (req, res, next) => {
multipartMiddleware(req, res, next);
};
middleware.proceedOnActivityPub = (req, res, next) => {
// For whatever reason, express accepts does not recognize "profile" as a valid differentiator
// Therefore, manual header parsing is used here.
const { accept } = req.headers;
if (!accept) {
return next('route');
}
const acceptable = [
'application/activity+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
];
const pass = accept.split(',').some((value) => {
const parts = value.split(';').map(v => v.trim());
return acceptable.includes(value || parts[0]);
});
if (!pass) {
return next('route');
}
next();
};