From f9f574532e3a6baca7e04190c78600c5b334aaa0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 14 May 2019 20:49:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=82=92=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 2 ++ src/client/app/admin/views/federation.vue | 36 +++++++++++++++++-- src/server/api/endpoints/admin/update-meta.ts | 11 ++++++ src/server/api/endpoints/meta.ts | 1 + 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c3bb4f7756..9390af40a9 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1486,6 +1486,8 @@ admin/views/federation.vue: chart-spans: hour: "1時間ごと" day: "1日ごと" + blocked-hosts: "ブロック" + blocked-hosts-info: "ブロックしたいホストを改行で区切って記述します。" desktop/views/pages/welcome.vue: about: "詳しく..." diff --git a/src/client/app/admin/views/federation.vue b/src/client/app/admin/views/federation.vue index 25400393b9..4d0b4b7c77 100644 --- a/src/client/app/admin/views/federation.vue +++ b/src/client/app/admin/views/federation.vue @@ -54,7 +54,6 @@ {{ $t('latest-request-received-at') }} - {{ $t('block') }} {{ $t('marked-as-closed') }}
{{ $t('charts') }} @@ -142,6 +141,16 @@ {{ $t('result-is-truncated', { n: limit }) }} + + + +
+ + + + {{ $t('save') }} +
+
@@ -149,7 +158,7 @@ import Vue from 'vue'; import i18n from '../../i18n'; import { faPaperPlane } from '@fortawesome/free-regular-svg-icons'; -import { faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faTrafficLight, faInbox } from '@fortawesome/free-solid-svg-icons'; +import { faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faTrafficLight, faInbox } from '@fortawesome/free-solid-svg-icons'; import ApexCharts from 'apexcharts'; import * as tinycolor from 'tinycolor2'; @@ -176,7 +185,8 @@ export default Vue.extend({ chartSrc: 'requests', chartSpan: 'hour', chartInstance: null, - faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faPaperPlane, faTrafficLight, faInbox + blockedHosts: '', + faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faPaperPlane, faTrafficLight, faInbox }; }, @@ -246,6 +256,10 @@ export default Vue.extend({ mounted() { this.fetchInstances(); + + this.$root.getMeta().then(meta => { + this.blockedHosts = meta.blockedHosts.join('\n'); + }); }, beforeDestroy() { @@ -477,6 +491,22 @@ export default Vue.extend({ }] }; }, + + saveBlockedHosts() { + this.$root.api('admin/update-meta', { + blockedHosts: this.blockedHosts.split('\n') + }).then(() => { + this.$root.dialog({ + type: 'success', + text: this.$t('saved') + }); + }).catch(e => { + this.$root.dialog({ + type: 'error', + text: e + }); + }); + } } }); diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index e34840e907..e4f2e86aaa 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -70,6 +70,13 @@ export const meta = { } }, + blockedHosts: { + validator: $.optional.nullable.arr($.str), + desc: { + 'ja-JP': 'ブロックするホスト' + } + }, + mascotImageUrl: { validator: $.optional.nullable.str, desc: { @@ -389,6 +396,10 @@ export default define(meta, async (ps) => { set.hiddenTags = ps.hiddenTags; } + if (Array.isArray(ps.blockedHosts)) { + set.blockedHosts = ps.blockedHosts; + } + if (ps.mascotImageUrl !== undefined) { set.mascotImageUrl = ps.mascotImageUrl; } diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index e29edae266..1bd88a1e6d 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -165,6 +165,7 @@ export default define(meta, async (ps, me) => { response.useStarForReactionFallback = instance.useStarForReactionFallback; response.pinnedUsers = instance.pinnedUsers; response.hiddenTags = instance.hiddenTags; + response.blockedHosts = instance.blockedHosts; response.recaptchaSecretKey = instance.recaptchaSecretKey; response.proxyAccount = instance.proxyAccount; response.twitterConsumerKey = instance.twitterConsumerKey;