mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: update proceedOnActivityPub middleware to handle how Mastodon doesn't send the 'Accepts' header
This commit is contained in:
@@ -101,7 +101,7 @@ Controller.getInbox = async (req, res) => {
|
||||
};
|
||||
|
||||
Controller.postInbox = async (req, res) => {
|
||||
// Note: internal-only, hence no exposure via src/api
|
||||
// Note: underlying methods are internal use only, hence no exposure via src/api
|
||||
switch (req.body.type) {
|
||||
case 'Follow': {
|
||||
await activitypub.inbox.follow(req.body.actor.name, req.body.object.name);
|
||||
|
||||
@@ -310,8 +310,8 @@ middleware.handleMultipart = (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 || !meta.config.activitypubEnabled) {
|
||||
const { accept, 'content-type': contentType } = req.headers;
|
||||
if (!meta.config.activitypubEnabled || !(accept && contentType)) {
|
||||
return next('route');
|
||||
}
|
||||
|
||||
@@ -319,10 +319,10 @@ middleware.proceedOnActivityPub = (req, res, next) => {
|
||||
'application/activity+json',
|
||||
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||
];
|
||||
const pass = accept.split(',').some((value) => {
|
||||
const pass = (accept && accept.split(',').some((value) => {
|
||||
const parts = value.split(';').map(v => v.trim());
|
||||
return acceptable.includes(value || parts[0]);
|
||||
});
|
||||
})) || (contentType && acceptable.includes(contentType));
|
||||
|
||||
if (!pass) {
|
||||
return next('route');
|
||||
|
||||
Reference in New Issue
Block a user