From 6c9356c945c15e415d4e2c03c611fc2ab069f677 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 29 Aug 2020 08:56:32 +0900 Subject: [PATCH] Expose proxyAccountName (#6670) --- src/server/api/endpoints/meta.ts | 4 ++++ src/server/nodeinfo.ts | 6 +++++- src/server/web/index.ts | 4 ++++ src/server/web/views/info.pug | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index f011a6751..f46139aa2 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -99,6 +99,8 @@ export default define(meta, async (ps, me) => { } }); + const proxyAccount = instance.proxyAccountId ? await Users.pack(instance.proxyAccountId).catch(() => null) : null; + const response: any = { maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, @@ -143,6 +145,8 @@ export default define(meta, async (ps, me) => { enableDiscordIntegration: instance.enableDiscordIntegration, enableServiceWorker: instance.enableServiceWorker, + + proxyAccountName: proxyAccount ? proxyAccount.username : null, }; if (ps.detail) { diff --git a/src/server/nodeinfo.ts b/src/server/nodeinfo.ts index b0de850dd..5c51137c9 100644 --- a/src/server/nodeinfo.ts +++ b/src/server/nodeinfo.ts @@ -1,6 +1,7 @@ import * as Router from '@koa/router'; import config from '../config'; import { fetchMeta } from '../misc/fetch-meta'; +import { Users } from '../models'; // import User from '../models/user'; // import Note from '../models/note'; @@ -34,6 +35,8 @@ const nodeinfo2 = async () => { // Note.count({ '_user.host': null, replyId: { $ne: null } }) ]); + const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null; + return { software: { name: 'misskey', @@ -72,7 +75,8 @@ const nodeinfo2 = async () => { enableGithubIntegration: meta.enableGithubIntegration, enableDiscordIntegration: meta.enableDiscordIntegration, enableEmail: meta.enableEmail, - enableServiceWorker: meta.enableServiceWorker + enableServiceWorker: meta.enableServiceWorker, + proxyAccountName: proxyAccount ? proxyAccount.username : null, } }; }; diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 18cd102eb..507ddac3c 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -326,6 +326,9 @@ router.get('/info', async ctx => { const emojis = await Emojis.find({ where: { host: null } }); + + const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null; + await ctx.render('info', { version: config.version, machine: os.hostname(), @@ -339,6 +342,7 @@ router.get('/info', async ctx => { }, emojis: emojis, meta: meta, + proxyAccountName: proxyAccount ? proxyAccount.username : null, originalUsersCount: await Users.count({ host: null }), originalNotesCount: await Notes.count({ userHost: null }) }); diff --git a/src/server/web/views/info.pug b/src/server/web/views/info.pug index 4553d2e2b..eed69fc99 100644 --- a/src/server/web/views/info.pug +++ b/src/server/web/views/info.pug @@ -79,6 +79,9 @@ html td = meta.maintainerName | <#{meta.maintainerEmail}> + tr + th Proxy account name + td= proxyAccountName || '(none)' tr th System td= os