Fix: unknown user cause 500 on AP (#5436)

This commit is contained in:
MeiMei 2019-09-20 05:14:21 +09:00 committed by syuilo
parent a942ed1e92
commit c29c202e11

View file

@ -146,7 +146,7 @@ router.get('/users/:user/publickey', async ctx => {
}); });
// user // user
async function userInfo(ctx: Router.IRouterContext, user: User) { async function userInfo(ctx: Router.IRouterContext, user: User | undefined) {
if (user == null) { if (user == null) {
ctx.status = 404; ctx.status = 404;
return; return;
@ -165,7 +165,7 @@ router.get('/users/:user', async (ctx, next) => {
const user = await Users.findOne({ const user = await Users.findOne({
id: userId, id: userId,
host: null host: null
}).then(ensure); });
await userInfo(ctx, user); await userInfo(ctx, user);
}); });
@ -176,7 +176,7 @@ router.get('/@:user', async (ctx, next) => {
const user = await Users.findOne({ const user = await Users.findOne({
usernameLower: ctx.params.user.toLowerCase(), usernameLower: ctx.params.user.toLowerCase(),
host: null host: null
}).then(ensure); });
await userInfo(ctx, user); await userInfo(ctx, user);
}); });