From 1d745ae99ccf9725b744dad52a412212efbe17a4 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Mon, 17 Dec 2018 13:48:14 -0800 Subject: [PATCH] Fixing follow bug Fixing an issue where I wasn't parsing the followers string on a DB query pre-write so followers would just not be written to the DB. --- routes/inbox.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/inbox.js b/routes/inbox.js index 8c582b9..b33cd2d 100644 --- a/routes/inbox.js +++ b/routes/inbox.js @@ -55,6 +55,9 @@ function sendAcceptMessage(thebody, name, domain, req, res, targetDomain) { router.post('/', function (req, res) { // pass in a name for an account, if the account doesn't exist, create it! let domain = req.app.get('domain'); + if (req.body.actor === undefined) { + return res.status(400).send(`No actor specified.`); + } const myURL = new URL(req.body.actor); let targetDomain = myURL.hostname; fs.appendFile('./inbox.log', JSON.stringify(req.body)+'\r\n', function (err) { @@ -76,8 +79,8 @@ router.post('/', function (req, res) { else { // update followers let followers = result.followers; - console.log(followers); if (followers) { + followers = JSON.parse(followers); followers.push(req.body.actor); // unique items followers = [...new Set(followers)];