Skip to content

Commit

Permalink
fix: missing req.body when parsing ActivityPub requests
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Jul 11, 2023
1 parent 890e701 commit 239a1d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/activitypub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}));
};
2 changes: 1 addition & 1 deletion src/controllers/activitypub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
8 changes: 7 additions & 1 deletion src/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,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));
}

Expand Down

0 comments on commit 239a1d7

Please sign in to comment.