diff --git a/package.json b/package.json index fa68958..4f6d3bc 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ }, "scripts": { "start": "node index.js", + "start:prod": "NODE_ENV=production authbind node index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Will Murphy", diff --git a/pub/activity.js b/pub/activity.js index 88434c1..df53542 100644 --- a/pub/activity.js +++ b/pub/activity.js @@ -64,7 +64,7 @@ function addToOutbox (actor, activity) { return Promise.all([ // ensure object is cached, but don't alter representation in activity // so activities can be sent with objects as links - pubObject.resolve(activity.object), + //pubObject.resolve(activity.object), store.stream.save(activity), address(activity).then(addresses => pubFederation.deliver(actor, activity, addresses)) ]) diff --git a/pub/federation.js b/pub/federation.js index d73707c..0c671cd 100644 --- a/pub/federation.js +++ b/pub/federation.js @@ -24,6 +24,7 @@ function deliver (actor, activity, addresses) { delete activity.bcc } const requests = addresses.map(addr => { + console.log(`delivering to${addr}`) return request({ method: 'POST', url: addr, @@ -37,8 +38,12 @@ function deliver (actor, activity, addresses) { authorizationHeaderName: 'Signature' }, json: true, + resolveWithFullResponse: true, + simple: false, body: pubUtils.toJSONLD(activity) }) + .then(result => console.log(addr, result.statusCode)) + .catch(err => console.log(err)) }) return Promise.all(requests) } diff --git a/routes/inbox.js b/routes/inbox.js index 97e6c05..f4de2b5 100644 --- a/routes/inbox.js +++ b/routes/inbox.js @@ -6,18 +6,19 @@ const store = require('../store') router.post('/', net.validators.activity, net.security.verifySignature, function (req, res) { req.body._meta = { _target: pub.utils.usernameToIRI(req.user) } + console.log(req.body); // side effects switch (req.body.type) { case 'Accept': // TODO - side effect necessary for following collection? break case 'Follow': - req.body._meta._target = req.body.object.id + //req.body._meta._target = req.body.object.id // send acceptance reply pub.actor.getOrCreateActor(req.user, true) .then(user => { const to = [pub.utils.actorFromActivity(req.body)] - const accept = pub.activity.build('Accept', user.id, req.body.id, to) + const accept = pub.activity.build('Accept', user.id, req.body, to) return pub.activity.addToOutbox(user, accept) }) .catch(e => console.log(e)) @@ -30,7 +31,7 @@ router.post('/', net.validators.activity, net.security.verifySignature, function pub.utils.actorFromActivity(req.body), 'https://www.w3.org/ns/activitystreams#Public' ] - const accept = pub.activity.build('Announce', user.id, req.body.id, to, cc) + const accept = pub.activity.build('Announce', user.id, req.body.object.id, to, cc) return pub.activity.addToOutbox(user, accept) }).catch(e => console.log(e)) break