diff options
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/meta.ts | 16 | ||||
| -rw-r--r-- | src/models/user.ts | 6 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/models/meta.ts b/src/models/meta.ts index 3eb73681ac..5d03d94181 100644 --- a/src/models/meta.ts +++ b/src/models/meta.ts @@ -1,5 +1,7 @@ import db from '../db/mongodb'; import config from '../config'; +import User from './user'; +import { transform } from '../misc/cafy-id'; const Meta = db.get<IMeta>('meta'); export default Meta; @@ -74,6 +76,18 @@ if ((config as any).recaptcha) { } }); } +if ((config as any).ghost) { + Meta.findOne({}).then(async m => { + if (m != null && m.proxyAccount == null) { + const account = await User.findOne({ _id: transform((config as any).ghost) }); + Meta.update({}, { + $set: { + proxyAccount: account.username + } + }); + } + }); +} export type IMeta = { name?: string; @@ -92,6 +106,8 @@ export type IMeta = { cacheRemoteFiles?: boolean; + proxyAccount?: string; + enableRecaptcha?: boolean; recaptchaSiteKey?: string; recaptchaSecretKey?: string; diff --git a/src/models/user.ts b/src/models/user.ts index 43ca612b51..2ca1917dc9 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -10,6 +10,7 @@ import Mute from './mute'; import { getFriendIds } from '../server/api/common/get-friends'; import config from '../config'; import FollowRequest from './follow-request'; +import fetchMeta from '../misc/fetch-meta'; const User = db.get<IUser>('users'); @@ -376,6 +377,7 @@ function img(url) { } */ -export function getGhost(): Promise<ILocalUser> { - return User.findOne({ _id: new mongo.ObjectId(config.ghost) }); +export async function fetchProxyAccount(): Promise<ILocalUser> { + const meta = await fetchMeta(); + return await User.findOne({ username: meta.proxyAccount, host: null }) as ILocalUser; } |