Skip to content

Node.js based forum software built for the modern web

fix: missing req.body when parsing ActivityPub requests

Julian Lame6753ce5dbf9
diff --git a/src/activitypub/index.js b/src/activitypub/index.js
index 4994e344e9..3bb2177a3c 100644
--- a/src/activitypub/index.js
+++ b/src/activitypub/index.js
@@ -194,6 +194,9 @@ ActivityPub.send = async (uid, targets, payload) => {
resolveWithFullResponse: true,
});
- console.log(response.statusCode, response.body);
+ if (response.statusCode !== 201) {
+ // todo: i18n this
+ throw new Error('activity-failed');
+ }
}));
};
diff --git a/src/controllers/activitypub/index.js b/src/controllers/activitypub/index.js
index a90d5a5a1b..f7e7dc460a 100644
--- a/src/controllers/activitypub/index.js
+++ b/src/controllers/activitypub/index.js
@@ -99,7 +99,7 @@ Controller.getInbox = async (req, res) => {
};
Controller.postInbox = async (req, res) => {
- console.log(req.body);
+ console.log('received', req.body);
res.sendStatus(201);
};
diff --git a/src/webserver.js b/src/webserver.js
index ff5031ff41..1b6d62d752 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -229,7 +229,13 @@ function configureBodyParser(app) {
}
app.use(bodyParser.urlencoded(urlencodedOpts));
- const jsonOpts = nconf.get('bodyParser:json') || {};
+ const jsonOpts = nconf.get('bodyParser:json') || {
+ type: [
+ 'application/json',
+ 'application/ld+json',
+ 'application/activity+json',
+ ],
+ };
app.use(bodyParser.json(jsonOpts));
}