From ff5ab7d12f34ab9eef592be6abc88459e6199453 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Apr 2018 22:17:55 +0900 Subject: Fix bug --- src/server/activitypub.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/server/activitypub.ts') diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index e27e2552f3..73ed43406d 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -1,3 +1,4 @@ +import * as mongo from 'mongodb'; import * as Router from 'koa-router'; const json = require('koa-json-body'); const httpSignature = require('http-signature'); @@ -49,7 +50,7 @@ router.get('/notes/:note', async (ctx, next) => { } const note = await Note.findOne({ - _id: ctx.params.note + _id: new mongo.ObjectID(ctx.params.note) }); if (note === null) { @@ -62,7 +63,7 @@ router.get('/notes/:note', async (ctx, next) => { // outbot router.get('/users/:user/outbox', async ctx => { - const userId = ctx.params.user; + const userId = new mongo.ObjectID(ctx.params.user); const user = await User.findOne({ _id: userId }); @@ -84,7 +85,7 @@ router.get('/users/:user/outbox', async ctx => { // publickey router.get('/users/:user/publickey', async ctx => { - const userId = ctx.params.user; + const userId = new mongo.ObjectID(ctx.params.user); const user = await User.findOne({ _id: userId }); @@ -102,7 +103,7 @@ router.get('/users/:user/publickey', async ctx => { // user router.get('/users/:user', async ctx => { - const userId = ctx.params.user; + const userId = new mongo.ObjectID(ctx.params.user); const user = await User.findOne({ _id: userId }); -- cgit v1.2.3-freya From 1131ce8a716b2cd2b4ed1253af40b26ae0631297 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 23 Apr 2018 15:37:27 +0900 Subject: sharedInboxを提供 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote/activitypub/renderer/person.ts | 1 + src/server/activitypub.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/server/activitypub.ts') diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts index f1c8056a75..424305f8d3 100644 --- a/src/remote/activitypub/renderer/person.ts +++ b/src/remote/activitypub/renderer/person.ts @@ -10,6 +10,7 @@ export default user => { id, inbox: `${id}/inbox`, outbox: `${id}/outbox`, + sharedInbox: `${config.url}/inbox`, url: `${config.url}/@${user.username}`, preferredUsername: user.username, name: user.name, diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index 73ed43406d..3c07a3e2f2 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -1,4 +1,5 @@ import * as mongo from 'mongodb'; +import * as Koa from 'koa'; import * as Router from 'koa-router'; const json = require('koa-json-body'); const httpSignature = require('http-signature'); @@ -19,8 +20,7 @@ const router = new Router(); //#region Routing -// inbox -router.post('/users/:user/inbox', json(), ctx => { +function inbox(ctx: Koa.Context) { let signature; ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature; @@ -39,7 +39,11 @@ router.post('/users/:user/inbox', json(), ctx => { }).save(); ctx.status = 202; -}); +} + +// inbox +router.post('/inbox', json(), inbox); +router.post('/users/:user/inbox', json(), inbox); // note router.get('/notes/:note', async (ctx, next) => { -- cgit v1.2.3-freya