From 0a1d84b753632fe491b9c1ef386dcbc60cd3974b Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Sun, 26 Jun 2022 20:27:05 +0200 Subject: [PATCH] Allow to execute locally on macOS Small fixes were necessary to run today on macOS. I've also added some debugging `console.log` around to understand better what is going on. --- README.md | 2 +- package.json | 2 +- routes/api.js | 2 +- routes/inbox.js | 7 +++++-- routes/webfinger.js | 2 ++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ee065ca..d611aa2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This requires Node.js v10.10.0 or above. Clone the repository, then `cd` into its root directory. Install dependencies: -`npm i` +`CXXFLAGS="--std=c++17" npm i` Copy `config-template.json` to `config.json`. diff --git a/package.json b/package.json index 3c36cbf..512b8d0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "dependencies": { - "better-sqlite3": "^5.4.0", + "better-sqlite3": "^7.5.3", "body-parser": "^1.18.3", "cors": "^2.8.4", "express": "^4.16.3", diff --git a/routes/api.js b/routes/api.js index 02f5a25..f4fe055 100644 --- a/routes/api.js +++ b/routes/api.js @@ -103,7 +103,7 @@ function sendCreateMessage(text, name, domain, req, res) { console.log(followers); console.log('type',typeof followers); if (followers === null) { - console.log('aaaa'); + console.log(`warn: No followers for account ${name}@${domain}`); res.status(400).json({msg: `No followers for account ${name}@${domain}`}); } else { diff --git a/routes/inbox.js b/routes/inbox.js index 8436378..daf1e80 100644 --- a/routes/inbox.js +++ b/routes/inbox.js @@ -71,16 +71,19 @@ function parseJSON(text) { 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'); + console.log(`Received ${JSON.stringify(req.body)}`); const myURL = new URL(req.body.actor); let targetDomain = myURL.hostname; // TODO: add "Undo" follow event if (typeof req.body.object === 'string' && req.body.type === 'Follow') { - let name = req.body.object.replace(`https://${domain}/u/`,''); + let name = req.body.object.replace(`http://${domain}/u/`,''); sendAcceptMessage(req.body, name, domain, req, res, targetDomain); // Add the user to the DB of accounts that follow the account let db = req.app.get('db'); // get the followers JSON for the user - let result = db.prepare('select followers from accounts where name = ?').get(`${name}@${domain}`); + const username = `${name}@${domain}`; + console.log(`Trying to find name in db = ${username}`); + let result = db.prepare('select followers from accounts where name = ?').get(username); if (result === undefined) { console.log(`No record found for ${name}.`); } diff --git a/routes/webfinger.js b/routes/webfinger.js index c743d84..19e55b4 100644 --- a/routes/webfinger.js +++ b/routes/webfinger.js @@ -3,8 +3,10 @@ const express = require('express'), router = express.Router(); router.get('/', function (req, res) { + console.log("here...."); let resource = req.query.resource; if (!resource || !resource.includes('acct:')) { + console.log("nothing in the query"); return res.status(400).send('Bad request. Please make sure "acct:USER@DOMAIN" is what you are sending as the "resource" query parameter.'); } else {