プロキシアカウントをユーザー名ではなくIDで保存するように

This commit is contained in:
syuilo
2020-02-05 10:15:09 +09:00
parent ce589fee8c
commit 8818648740
8 changed files with 67 additions and 22 deletions

View File

@ -1,9 +1,9 @@
import { fetchMeta } from './fetch-meta';
import { ILocalUser } from '../models/entities/user';
import { Users } from '../models';
import { ensure } from '../prelude/ensure';
export async function fetchProxyAccount(): Promise<ILocalUser> {
export async function fetchProxyAccount(): Promise<ILocalUser | null> {
if (meta.proxyAccountId == null) return null;
const meta = await fetchMeta();
return await Users.findOne({ username: meta.proxyAccount!, host: null }).then(ensure) as ILocalUser;
return await Users.findOne(meta.proxyAccountId);
}