From b28dd4be5238f2f36b573b39e689fc816fadda48 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 1 Sep 2018 23:29:22 +0900 Subject: Use typeof --- src/server/api/endpoints/admin/update-meta.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/api/endpoints/admin/update-meta.ts') diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 2c7929fabe..9737a281ed 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -25,7 +25,7 @@ export default (params: any) => new Promise(async (res, rej) => { const set = {} as any; - if (ps.disableRegistration === true || ps.disableRegistration === false) { + if (typeof ps.disableRegistration === 'boolean') { set.disableRegistration = ps.disableRegistration; } -- cgit v1.2.3-freya From 66f3a155e6050fc297d2f600e6d619c5dba0f764 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 3 Sep 2018 23:23:50 +0900 Subject: なんかもうめっちゃやった MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/common/views/components/signin.vue | 2 +- src/client/app/common/views/widgets/broadcast.vue | 10 +- .../views/pages/admin/admin.announcements.vue | 41 +++ src/client/app/desktop/views/pages/admin/admin.vue | 6 + src/client/app/desktop/views/pages/welcome.vue | 309 ++++++++++----------- src/server/api/endpoints/admin/update-meta.ts | 12 +- 6 files changed, 205 insertions(+), 175 deletions(-) create mode 100644 src/client/app/desktop/views/pages/admin/admin.announcements.vue (limited to 'src/server/api/endpoints/admin/update-meta.ts') diff --git a/src/client/app/common/views/components/signin.vue b/src/client/app/common/views/components/signin.vue index 5230ac371a..b1c6782e93 100644 --- a/src/client/app/common/views/components/signin.vue +++ b/src/client/app/common/views/components/signin.vue @@ -78,7 +78,7 @@ export default Vue.extend({ cursor wait !important > .avatar - margin 16px auto 0 auto + margin 0 auto 0 auto width 64px height 64px background #ddd diff --git a/src/client/app/common/views/widgets/broadcast.vue b/src/client/app/common/views/widgets/broadcast.vue index 69b2a54fe9..d3a39bd9cc 100644 --- a/src/client/app/common/views/widgets/broadcast.vue +++ b/src/client/app/common/views/widgets/broadcast.vue @@ -42,15 +42,7 @@ export default define({ }, mounted() { (this as any).os.getMeta().then(meta => { - let broadcasts = []; - if (meta.broadcasts) { - meta.broadcasts.forEach(broadcast => { - if (broadcast[lang]) { - broadcasts.push(broadcast[lang]); - } - }); - } - this.broadcasts = broadcasts; + this.broadcasts = meta.broadcasts; this.fetching = false; }); }, diff --git a/src/client/app/desktop/views/pages/admin/admin.announcements.vue b/src/client/app/desktop/views/pages/admin/admin.announcements.vue new file mode 100644 index 0000000000..532400deb2 --- /dev/null +++ b/src/client/app/desktop/views/pages/admin/admin.announcements.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/client/app/desktop/views/pages/admin/admin.vue b/src/client/app/desktop/views/pages/admin/admin.vue index 3438462cd6..a71059c378 100644 --- a/src/client/app/desktop/views/pages/admin/admin.vue +++ b/src/client/app/desktop/views/pages/admin/admin.vue @@ -4,6 +4,7 @@ @@ -13,6 +14,9 @@ +
+ +
@@ -28,6 +32,7 @@ - - - diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 9737a281ed..10ca15d329 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -11,11 +11,17 @@ export const meta = { requireAdmin: true, params: { + broadcasts: $.arr($.obj()).optional.nullable.note({ + desc: { + 'ja-JP': 'ブロードキャスト' + } + }), + disableRegistration: $.bool.optional.nullable.note({ desc: { 'ja-JP': '招待制か否か' } - }), + }) } }; @@ -25,6 +31,10 @@ export default (params: any) => new Promise(async (res, rej) => { const set = {} as any; + if (ps.broadcasts) { + set.broadcasts = ps.broadcasts; + } + if (typeof ps.disableRegistration === 'boolean') { set.disableRegistration = ps.disableRegistration; } -- cgit v1.2.3-freya From 7343e6e2e8e94b2a58943c62c047b5a7c4116e3a Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 7 Sep 2018 19:20:50 +0900 Subject: 統計で無視するハッシュタグを設定できるように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desktop/views/pages/admin/admin.hashtags.vue | 41 ++++++++++++++++++++++ src/client/app/desktop/views/pages/admin/admin.vue | 7 ++++ src/models/meta.ts | 7 ++-- src/server/api/endpoints/admin/update-meta.ts | 12 ++++++- src/server/api/endpoints/hashtags/trend.ts | 7 ++++ src/server/api/endpoints/meta.ts | 6 ++-- 6 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/client/app/desktop/views/pages/admin/admin.hashtags.vue (limited to 'src/server/api/endpoints/admin/update-meta.ts') diff --git a/src/client/app/desktop/views/pages/admin/admin.hashtags.vue b/src/client/app/desktop/views/pages/admin/admin.hashtags.vue new file mode 100644 index 0000000000..c6bf20361f --- /dev/null +++ b/src/client/app/desktop/views/pages/admin/admin.hashtags.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/client/app/desktop/views/pages/admin/admin.vue b/src/client/app/desktop/views/pages/admin/admin.vue index a71059c378..510252b447 100644 --- a/src/client/app/desktop/views/pages/admin/admin.vue +++ b/src/client/app/desktop/views/pages/admin/admin.vue @@ -5,6 +5,8 @@
  • %fa:chalkboard .fw%%i18n:@dashboard%
  • %fa:users .fw%%i18n:@users%
  • %fa:broadcast-tower .fw%%i18n:@announcements%
  • +
  • %fa:hashtag .fw%%i18n:@hashtags%
  • + @@ -17,6 +19,9 @@
    +
    + +
    @@ -33,6 +38,7 @@ import Vue from "vue"; import XDashboard from "./admin.dashboard.vue"; import XAnnouncements from "./admin.announcements.vue"; +import XHashtags from "./admin.hashtags.vue"; import XSuspendUser from "./admin.suspend-user.vue"; import XUnsuspendUser from "./admin.unsuspend-user.vue"; import XVerifyUser from "./admin.verify-user.vue"; @@ -43,6 +49,7 @@ export default Vue.extend({ components: { XDashboard, XAnnouncements, + XHashtags, XSuspendUser, XUnsuspendUser, XVerifyUser, diff --git a/src/models/meta.ts b/src/models/meta.ts index aef0163dfe..4f1977f3b5 100644 --- a/src/models/meta.ts +++ b/src/models/meta.ts @@ -4,12 +4,13 @@ const Meta = db.get('meta'); export default Meta; export type IMeta = { - broadcasts: any[]; - stats: { + broadcasts?: any[]; + stats?: { notesCount: number; originalNotesCount: number; usersCount: number; originalUsersCount: number; }; - disableRegistration: boolean; + disableRegistration?: boolean; + hidedTags?: string[]; }; diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 10ca15d329..f903628774 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -21,7 +21,13 @@ export const meta = { desc: { 'ja-JP': '招待制か否か' } - }) + }), + + hidedTags: $.arr($.str).optional.nullable.note({ + desc: { + 'ja-JP': '統計などで無視するハッシュタグ' + } + }), } }; @@ -39,6 +45,10 @@ export default (params: any) => new Promise(async (res, rej) => { set.disableRegistration = ps.disableRegistration; } + if (Array.isArray(ps.hidedTags)) { + set.hidedTags = ps.hidedTags; + } + await Meta.update({}, { $set: set }, { upsert: true }); diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index e7c08ca9f0..bfa475619c 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -1,5 +1,6 @@ import Note from '../../../../models/note'; import { erase } from '../../../../prelude/array'; +import Meta from '../../../../models/meta'; /* トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要 @@ -17,6 +18,9 @@ const max = 5; * Get trends of hashtags */ export default () => new Promise(async (res, rej) => { + const meta = await Meta.findOne({}); + const hidedTags = (meta.hidedTags || []).map(t => t.toLowerCase()); + //#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計 const data = await Note.aggregate([{ $match: { @@ -53,6 +57,9 @@ export default () => new Promise(async (res, rej) => { // カウント data.map(x => x._id).forEach(x => { + // ブラックリストに登録されているタグなら弾く + if (hidedTags.includes(x.tag)) return; + const i = tags.findIndex(tag => tag.name == x.tag); if (i != -1) { tags[i].count++; diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index b0876eaafd..4472d8d779 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -4,6 +4,7 @@ import * as os from 'os'; import config from '../../../config'; import Meta from '../../../models/meta'; +import { ILocalUser } from '../../../models/user'; const pkg = require('../../../../package.json'); const client = require('../../../../built/client/meta.json'); @@ -11,7 +12,7 @@ const client = require('../../../../built/client/meta.json'); /** * Show core info */ -export default () => new Promise(async (res, rej) => { +export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { const meta: any = (await Meta.findOne()) || {}; res({ @@ -35,6 +36,7 @@ export default () => new Promise(async (res, rej) => { disableRegistration: meta.disableRegistration, driveCapacityPerLocalUserMb: config.localDriveCapacityMb, recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null, - swPublickey: config.sw ? config.sw.public_key : null + swPublickey: config.sw ? config.sw.public_key : null, + hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined }); }); -- cgit v1.2.3-freya From 046976dffc1aa8bc02259ab4a65e74b1216a0ec3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 12 Sep 2018 02:48:19 +0900 Subject: Resolve #2691 --- .../app/desktop/views/components/timeline.vue | 11 +- .../desktop/views/pages/admin/admin.dashboard.vue | 35 ++++-- src/client/app/mobile/views/pages/home.vue | 11 +- src/models/meta.ts | 1 + src/server/api/endpoints/admin/update-meta.ts | 10 ++ src/server/api/endpoints/meta.ts | 1 + src/stream.ts | 119 ++++++++++++++------- 7 files changed, 134 insertions(+), 54 deletions(-) (limited to 'src/server/api/endpoints/admin/update-meta.ts') diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index 52a7753438..8d72016f22 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -2,8 +2,8 @@
    %fa:home% %i18n:@home% - %fa:R comments% %i18n:@local% - %fa:share-alt% %i18n:@hybrid% + %fa:R comments% %i18n:@local% + %fa:share-alt% %i18n:@hybrid% %fa:globe% %i18n:@global% %fa:list% {{ list.title }} @@ -29,7 +29,8 @@ export default Vue.extend({ data() { return { src: 'home', - list: null + list: null, + enableLocalTimeline: false }; }, @@ -44,6 +45,10 @@ export default Vue.extend({ }, created() { + (this as any).os.getMeta().then(meta => { + this.enableLocalTimeline = !meta.disableLocalTimeline; + }); + if (this.$store.state.device.tl) { this.src = this.$store.state.device.tl.src; if (this.src == 'list') { diff --git a/src/client/app/desktop/views/pages/admin/admin.dashboard.vue b/src/client/app/desktop/views/pages/admin/admin.dashboard.vue index ebb54d782e..c86c30db17 100644 --- a/src/client/app/desktop/views/pages/admin/admin.dashboard.vue +++ b/src/client/app/desktop/views/pages/admin/admin.dashboard.vue @@ -1,22 +1,34 @@ @@ -33,6 +45,7 @@ export default Vue.extend({ return { stats: null, disableRegistration: false, + disableLocalTimeline: false, inviteCode: null, connection: null, connectionId: null @@ -44,6 +57,7 @@ export default Vue.extend({ (this as any).os.getMeta().then(meta => { this.disableRegistration = meta.disableRegistration; + this.disableLocalTimeline = meta.disableLocalTimeline; }); (this as any).api('stats').then(stats => { @@ -61,7 +75,8 @@ export default Vue.extend({ }, updateMeta() { (this as any).api('admin/update-meta', { - disableRegistration: this.disableRegistration + disableRegistration: this.disableRegistration, + disableLocalTimeline: this.disableLocalTimeline }); } } @@ -97,4 +112,8 @@ export default Vue.extend({ border solid 1px #eee border-radius: 8px + > .form + > div + border-bottom solid 1px #eee + diff --git a/src/client/app/mobile/views/pages/home.vue b/src/client/app/mobile/views/pages/home.vue index 706c9cd28b..333ca1a7a1 100644 --- a/src/client/app/mobile/views/pages/home.vue +++ b/src/client/app/mobile/views/pages/home.vue @@ -24,8 +24,8 @@
    %fa:home% %i18n:@home% - %fa:R comments% %i18n:@local% - %fa:share-alt% %i18n:@hybrid% + %fa:R comments% %i18n:@local% + %fa:share-alt% %i18n:@hybrid% %fa:globe% %i18n:@global%