From bb04ef0664d39edd481cbb55feb9a7a5ba5b0767 Mon Sep 17 00:00:00 2001 From: Armin Date: Thu, 28 Feb 2019 03:43:44 +0100 Subject: [PATCH] Refactoring --- src/activitypub/NitroDataSource.js | 2 +- src/activitypub/routes/inbox.js | 3 --- src/activitypub/routes/index.js | 8 +++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/activitypub/NitroDataSource.js b/src/activitypub/NitroDataSource.js index 11be287d7..20339ec62 100644 --- a/src/activitypub/NitroDataSource.js +++ b/src/activitypub/NitroDataSource.js @@ -339,7 +339,7 @@ export default class NitroDataSource { let result = await this.client.mutate({ mutation: gql` mutation { - CreatePost(content: "${postObject.content}", title: "${title}", id: "${postId}", activityId: "${activityId}") { + CreatePost(content: "${postObject.content}", contentExcerpt: "${trunc(postObject.content, 120)}", title: "${title}", id: "${postId}", activityId: "${activityId}") { id } } diff --git a/src/activitypub/routes/inbox.js b/src/activitypub/routes/inbox.js index eb720e042..062f4b916 100644 --- a/src/activitypub/routes/inbox.js +++ b/src/activitypub/routes/inbox.js @@ -1,5 +1,4 @@ import express from 'express' -import { verifySignature } from '../security' import { activityPub } from '../ActivityPub' const debug = require('debug')('ea:inbox') @@ -12,8 +11,6 @@ router.post('/', async function (req, res, next) { debug(`Content-Type = ${req.get('Content-Type')}`) debug(`body = ${JSON.stringify(req.body, null, 2)}`) debug(`Request headers = ${JSON.stringify(req.headers, null, 2)}`) - // TODO stop if signature validation fails - debug(`verify = ${await verifySignature(`${req.protocol}://${req.hostname}:${req.port}${req.originalUrl}`, req.headers)}`) switch (req.body.type) { case 'Create': if (req.body.send) { diff --git a/src/activitypub/routes/index.js b/src/activitypub/routes/index.js index 7a8524a9e..24898e766 100644 --- a/src/activitypub/routes/index.js +++ b/src/activitypub/routes/index.js @@ -1,15 +1,16 @@ import user from './user' import inbox from './inbox' -import webfinger from './webfinger' +import webFinger from './webFinger' import express from 'express' import cors from 'cors' +import verify from './verify' const router = express.Router() -router.use('/.well-known/webfinger', +router.use('/.well-known/webFinger', cors(), express.urlencoded({ extended: true }), - webfinger + webFinger ) router.use('/activitypub/users', cors(), @@ -21,6 +22,7 @@ router.use('/activitypub/inbox', cors(), express.json({ type: ['application/activity+json', 'application/ld+json', 'application/json'] }), express.urlencoded({ extended: true }), + verify, inbox )