Use id in uri instead of username

This commit is contained in:
syuilo
2018-04-08 15:15:22 +09:00
parent 1fced8a59b
commit e63f884bc6
14 changed files with 52 additions and 87 deletions

View File

@@ -1,18 +1,19 @@
import * as express from 'express';
import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/key';
import config from '../../config';
import withUser from './with-user';
import User from '../../models/user';
const app = express.Router();
app.get('/@:user/publickey', withUser(username => {
return `${config.url}/@${username}/publickey`;
}, (user, req, res) => {
app.get('/users/:user/publickey', async (req, res) => {
const userId = req.params.user;
const user = await User.findOne({ _id: userId });
const rendered = render(user);
rendered['@context'] = context;
res.json(rendered);
}));
});
export default app;