forked from FoundKeyGang/FoundKey
Check whether is local user
This commit is contained in:
parent
29619bb33f
commit
5fb08b0ba1
1 changed files with 8 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import context from '../../remote/activitypub/renderer/context';
|
import context from '../../remote/activitypub/renderer/context';
|
||||||
import render from '../../remote/activitypub/renderer/key';
|
import render from '../../remote/activitypub/renderer/key';
|
||||||
import User from '../../models/user';
|
import User, { isLocalUser } from '../../models/user';
|
||||||
|
|
||||||
const app = express.Router();
|
const app = express.Router();
|
||||||
|
|
||||||
|
@ -10,10 +10,14 @@ app.get('/users/:user/publickey', async (req, res) => {
|
||||||
|
|
||||||
const user = await User.findOne({ _id: userId });
|
const user = await User.findOne({ _id: userId });
|
||||||
|
|
||||||
const rendered = render(user);
|
if (isLocalUser(user)) {
|
||||||
rendered['@context'] = context;
|
const rendered = render(user);
|
||||||
|
rendered['@context'] = context;
|
||||||
|
|
||||||
res.json(rendered);
|
res.json(rendered);
|
||||||
|
} else {
|
||||||
|
res.sendStatus(400);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
Loading…
Reference in a new issue