diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-03 01:36:55 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-03 01:36:55 +0900 |
| commit | f8ebbfac0f5b5a0062411e8e2c564c0593a1fb10 (patch) | |
| tree | 94316f84f047907d25fe9ae6cd89c8ece873e883 /src/server/activitypub | |
| parent | Fix (diff) | |
| download | sharkey-f8ebbfac0f5b5a0062411e8e2c564c0593a1fb10.tar.gz sharkey-f8ebbfac0f5b5a0062411e8e2c564c0593a1fb10.tar.bz2 sharkey-f8ebbfac0f5b5a0062411e8e2c564c0593a1fb10.zip | |
Revert "Fix"
This reverts commit 8afdb5aef91bea931c1ab7ecfd9f5ba1e977652c.
Diffstat (limited to 'src/server/activitypub')
| -rw-r--r-- | src/server/activitypub/post.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/server/activitypub/post.ts b/src/server/activitypub/post.ts index 1dadad0db8..91d91aeb95 100644 --- a/src/server/activitypub/post.ts +++ b/src/server/activitypub/post.ts @@ -1,32 +1,40 @@ import * as express from 'express'; import context from '../../remote/activitypub/renderer/context'; import render from '../../remote/activitypub/renderer/note'; +import parseAcct from '../../acct/parse'; import Post from '../../models/post'; import User from '../../models/user'; const app = express(); app.disable('x-powered-by'); -app.get('/posts/:post', async (req, res, next) => { +app.get('/@:user/:post', async (req, res, next) => { const accepted = req.accepts(['html', 'application/activity+json', 'application/ld+json']); if (!(['application/activity+json', 'application/ld+json'] as any[]).includes(accepted)) { return next(); } - const post = await Post.findOne({ - _id: req.params.post - }); - if (post === null) { - return res.sendStatus(404); + const { username, host } = parseAcct(req.params.user); + if (host !== null) { + return res.sendStatus(422); } const user = await User.findOne({ - _id: post.userId + usernameLower: username.toLowerCase(), + host: null }); if (user === null) { return res.sendStatus(404); } + const post = await Post.findOne({ + _id: req.params.post, + userId: user._id + }); + if (post === null) { + return res.sendStatus(404); + } + const rendered = await render(user, post); rendered['@context'] = context; |