From 31802c97494c27f019c127077d7f1d88fd753fb8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 25 Feb 2019 03:21:54 +0900 Subject: [PATCH] Improve doc --- src/client/app/admin/views/announcements.vue | 4 +- .../app/common/views/widgets/broadcast.vue | 4 +- .../app/desktop/views/pages/welcome.vue | 2 +- .../app/mobile/views/components/ui.nav.vue | 2 +- src/client/app/mobile/views/pages/welcome.vue | 2 +- src/models/meta.ts | 11 +++- src/server/api/endpoints/admin/update-meta.ts | 8 +-- src/server/api/endpoints/drive.ts | 14 +++++- src/server/api/endpoints/meta.ts | 50 ++++++++++++++++++- src/server/nodeinfo.ts | 4 +- 10 files changed, 85 insertions(+), 16 deletions(-) diff --git a/src/client/app/admin/views/announcements.vue b/src/client/app/admin/views/announcements.vue index 64ac2615c8..2e64e47d95 100644 --- a/src/client/app/admin/views/announcements.vue +++ b/src/client/app/admin/views/announcements.vue @@ -35,7 +35,7 @@ export default Vue.extend({ created() { this.$root.getMeta().then(meta => { - this.announcements = meta.broadcasts; + this.announcements = meta.announcements; }); }, @@ -65,7 +65,7 @@ export default Vue.extend({ save(silent) { this.$root.api('admin/update-meta', { - broadcasts: this.announcements + announcements: this.announcements }).then(() => { if (!silent) { this.$root.dialog({ diff --git a/src/client/app/common/views/widgets/broadcast.vue b/src/client/app/common/views/widgets/broadcast.vue index 1222c3956d..f8897da253 100644 --- a/src/client/app/common/views/widgets/broadcast.vue +++ b/src/client/app/common/views/widgets/broadcast.vue @@ -16,7 +16,7 @@

{{ $t('fetching') }}

-

{{ announcements.length == 0 ? this.$t('no-broadcasts') : announcements[i].title }}

+

{{ announcements.length == 0 ? $t('no-broadcasts') : announcements[i].title }}

@@ -47,7 +47,7 @@ export default define({ }, mounted() { this.$root.getMeta().then(meta => { - this.announcements = meta.broadcasts; + this.announcements = meta.announcements; this.fetching = false; }); }, diff --git a/src/client/app/desktop/views/pages/welcome.vue b/src/client/app/desktop/views/pages/welcome.vue index 88a11eafa6..3c34989f79 100644 --- a/src/client/app/desktop/views/pages/welcome.vue +++ b/src/client/app/desktop/views/pages/welcome.vue @@ -174,7 +174,7 @@ export default Vue.extend({ this.meta = meta; this.name = meta.name; this.description = meta.description; - this.announcements = meta.broadcasts; + this.announcements = meta.announcements; this.banner = meta.bannerUrl; }); diff --git a/src/client/app/mobile/views/components/ui.nav.vue b/src/client/app/mobile/views/components/ui.nav.vue index 26da9d668c..627a322e6c 100644 --- a/src/client/app/mobile/views/components/ui.nav.vue +++ b/src/client/app/mobile/views/components/ui.nav.vue @@ -82,7 +82,7 @@ export default Vue.extend({ mounted() { this.$root.getMeta().then(meta => { - this.announcements = meta.broadcasts; + this.announcements = meta.announcements; }); if (this.$store.getters.isSignedIn) { diff --git a/src/client/app/mobile/views/pages/welcome.vue b/src/client/app/mobile/views/pages/welcome.vue index acc4eef792..cf5ac5f072 100644 --- a/src/client/app/mobile/views/pages/welcome.vue +++ b/src/client/app/mobile/views/pages/welcome.vue @@ -98,7 +98,7 @@ export default Vue.extend({ this.meta = meta; this.name = meta.name; this.description = meta.description; - this.announcements = meta.broadcasts; + this.announcements = meta.announcements; this.banner = meta.bannerUrl; }); diff --git a/src/models/meta.ts b/src/models/meta.ts index e5b729ea16..9e4468032c 100644 --- a/src/models/meta.ts +++ b/src/models/meta.ts @@ -151,6 +151,15 @@ if ((config as any).sw) { } }); } +Meta.findOne({}).then(m => { + if (m != null && (m as any).broadcasts != null) { + Meta.update({}, { + $rename: { + broadcasts: 'announcements' + } + }); + } +}); export type IMeta = { name?: string; @@ -173,7 +182,7 @@ export type IMeta = { langs?: string[]; - broadcasts?: any[]; + announcements?: any[]; stats?: { notesCount: number; diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 46fdeff759..5d08a6e37e 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -13,10 +13,10 @@ export const meta = { requireModerator: true, params: { - broadcasts: { + announcements: { validator: $.optional.nullable.arr($.obj()), desc: { - 'ja-JP': 'ブロードキャスト' + 'ja-JP': 'お知らせ' } }, @@ -328,8 +328,8 @@ export const meta = { export default define(meta, async (ps) => { const set = {} as any; - if (ps.broadcasts) { - set.broadcasts = ps.broadcasts; + if (ps.announcements) { + set.announcements = ps.announcements; } if (typeof ps.disableRegistration === 'boolean') { diff --git a/src/server/api/endpoints/drive.ts b/src/server/api/endpoints/drive.ts index 9c4482f915..138adffad2 100644 --- a/src/server/api/endpoints/drive.ts +++ b/src/server/api/endpoints/drive.ts @@ -12,7 +12,19 @@ export const meta = { requireCredential: true, - kind: 'drive-read' + kind: 'drive-read', + + res: { + type: 'object', + properties: { + capacity: { + type: 'number' + }, + usage: { + type: 'number' + } + } + } }; export default define(meta, async (ps, user) => { diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 07a475d4c2..d7099ea045 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -24,6 +24,54 @@ export const meta = { default: true } }, + + res: { + type: 'object', + properties: { + version: { + type: 'string', + description: 'The version of Misskey of this instance.', + example: pkg.version + }, + name: { + type: 'string', + description: 'The name of this instance.', + }, + description: { + type: 'string', + description: 'The description of this instance.', + }, + announcements: { + type: 'array', + items: { + type: 'object', + properties: { + title: { + type: 'string', + description: 'The title of the announcement.', + }, + text: { + type: 'string', + description: 'The text of the announcement. (can be HTML)', + }, + } + }, + description: 'The description of this instance.', + }, + disableRegistration: { + type: 'boolean', + description: 'Whether disabled open registration.', + }, + disableLocalTimeline: { + type: 'boolean', + description: 'Whether disabled LTL and STL.', + }, + disableGlobalTimeline: { + type: 'boolean', + description: 'Whether disabled GTL.', + }, + } + } }; export default define(meta, async (ps, me) => { @@ -55,7 +103,7 @@ export default define(meta, async (ps, me) => { cores: os.cpus().length }, - broadcasts: instance.broadcasts || [], + announcements: instance.announcements || [], disableRegistration: instance.disableRegistration, disableLocalTimeline: instance.disableLocalTimeline, disableGlobalTimeline: instance.disableGlobalTimeline, diff --git a/src/server/nodeinfo.ts b/src/server/nodeinfo.ts index 9e4ce37b81..a783eea90b 100644 --- a/src/server/nodeinfo.ts +++ b/src/server/nodeinfo.ts @@ -20,7 +20,7 @@ export const links = [/* (awaiting release) { const nodeinfo2 = async () => { const [ - { name, description, maintainer, langs, broadcasts, disableRegistration, disableLocalTimeline, disableGlobalTimeline, enableRecaptcha, maxNoteTextLength, enableTwitterIntegration, enableGithubIntegration, enableDiscordIntegration, enableEmail, enableServiceWorker }, + { name, description, maintainer, langs, announcements, disableRegistration, disableLocalTimeline, disableGlobalTimeline, enableRecaptcha, maxNoteTextLength, enableTwitterIntegration, enableGithubIntegration, enableDiscordIntegration, enableEmail, enableServiceWorker }, // total, // activeHalfyear, // activeMonth, @@ -52,7 +52,7 @@ const nodeinfo2 = async () => { // localPosts, // localComments }, - metadata: { name, description, maintainer, langs, broadcasts, disableRegistration, disableLocalTimeline, disableGlobalTimeline, enableRecaptcha, maxNoteTextLength, enableTwitterIntegration, enableGithubIntegration, enableDiscordIntegration, enableEmail, enableServiceWorker } + metadata: { name, description, maintainer, langs, announcements, disableRegistration, disableLocalTimeline, disableGlobalTimeline, enableRecaptcha, maxNoteTextLength, enableTwitterIntegration, enableGithubIntegration, enableDiscordIntegration, enableEmail, enableServiceWorker } }; };