mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 20:11:26 +01:00
feat: activitypub actor endpoint for user accounts
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user