Implement account public key endpoint
This commit is contained in:
parent
a3cef6e9b5
commit
cba73d6bc1
6 changed files with 66 additions and 52 deletions
23
src/server/activitypub/with-user.ts
Normal file
23
src/server/activitypub/with-user.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import parseAcct from '../../common/user/parse-acct';
|
||||
import User from '../../models/user';
|
||||
|
||||
export default (redirect, respond) => async (req, res, next) => {
|
||||
const { username, host } = parseAcct(req.params.user);
|
||||
if (host !== null) {
|
||||
return res.sendStatus(422);
|
||||
}
|
||||
|
||||
const user = await User.findOne({
|
||||
usernameLower: username.toLowerCase(),
|
||||
host: null
|
||||
});
|
||||
if (user === null) {
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
|
||||
if (username !== user.username) {
|
||||
return res.redirect(redirect(user.username));
|
||||
}
|
||||
|
||||
return respond(user, req, res, next);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue