From 3220d69a6930151f33928b5d789150aacc4bc382 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 14 Sep 2018 20:11:01 +0900 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E3=81=AB=E3=83=A1=E3=83=87=E3=82=A3?= =?UTF-8?q?=E3=82=A2=E3=82=92=E9=96=B2=E8=A6=A7=E6=B3=A8=E6=84=8F=E3=81=A8?= =?UTF-8?q?=E3=81=97=E3=81=A6=E6=8A=95=E7=A8=BF=E3=81=99=E3=82=8B=E3=82=AA?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 1 + .../app/desktop/views/components/settings.profile.vue | 7 +++++++ .../mobile/views/pages/settings/settings.profile.vue | 8 ++++++++ src/models/user.ts | 5 ++++- src/server/api/endpoints/drive/files/create.ts | 4 ++-- src/server/api/endpoints/i/update.ts | 7 +++++++ src/services/drive/add-file.ts | 10 ++++++++-- 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index aaa06bdd1d..134ec33831 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -117,6 +117,7 @@ common: verified-user: "公式アカウント" disable-animated-mfm: "投稿内の動きのあるテキストを無効にする" always-show-nsfw: "常に閲覧注意のメディアを表示する" + always-mark-nsfw: "常にメディアを閲覧注意として投稿" this-setting-is-this-device-only: "このデバイスのみ" do-not-use-in-production: 'これは開発ビルドです。本番環境で使用しないでください。' diff --git a/src/client/app/desktop/views/components/settings.profile.vue b/src/client/app/desktop/views/components/settings.profile.vue index 262583b640..0f53941b31 100644 --- a/src/client/app/desktop/views/components/settings.profile.vue +++ b/src/client/app/desktop/views/components/settings.profile.vue @@ -30,6 +30,7 @@

%i18n:@other%

+ @@ -46,6 +47,12 @@ export default Vue.extend({ birthday: null, }; }, + computed: { + alwaysMarkNsfw: { + get() { return this.$store.state.i.settings.alwaysMarkNsfw; }, + set(value) { (this as any).api('i/update', { alwaysMarkNsfw: value }); } + }, + }, created() { this.name = this.$store.state.i.name || ''; this.location = this.$store.state.i.profile.location; diff --git a/src/client/app/mobile/views/pages/settings/settings.profile.vue b/src/client/app/mobile/views/pages/settings/settings.profile.vue index 6f5ac9ae93..127f531902 100644 --- a/src/client/app/mobile/views/pages/settings/settings.profile.vue +++ b/src/client/app/mobile/views/pages/settings/settings.profile.vue @@ -49,6 +49,7 @@
%i18n:@is-cat% + %i18n:common.always-mark-nsfw%
@@ -85,6 +86,13 @@ export default Vue.extend({ }; }, + computed: { + alwaysMarkNsfw: { + get() { return this.$store.state.i.settings.alwaysMarkNsfw; }, + set(value) { (this as any).api('i/update', { alwaysMarkNsfw: value }); } + }, + }, + created() { this.name = this.$store.state.i.name || ''; this.username = this.$store.state.i.username; diff --git a/src/models/user.ts b/src/models/user.ts index 8f3fbbdc8f..64197c91c2 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -102,7 +102,10 @@ export interface ILocalUser extends IUserBase { twoFactorEnabled: boolean; twoFactorTempSecret?: string; clientSettings: any; - settings: any; + settings: { + autoWatch: boolean; + alwaysMarkNsfw?: boolean; + }; hasUnreadNotification: boolean; hasUnreadMessagingMessage: boolean; } diff --git a/src/server/api/endpoints/drive/files/create.ts b/src/server/api/endpoints/drive/files/create.ts index dfbd11d0c2..4b5ffa90e0 100644 --- a/src/server/api/endpoints/drive/files/create.ts +++ b/src/server/api/endpoints/drive/files/create.ts @@ -31,8 +31,8 @@ export const meta = { } }), - isSensitive: $.bool.optional.note({ - default: false, + isSensitive: $.bool.optional.nullable.note({ + default: null, desc: { 'ja-JP': 'このメディアが「閲覧注意」(NSFW)かどうか', 'en-US': 'Whether this media is NSFW' diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 6aa4cc1148..c1be0b6ebc 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -84,6 +84,12 @@ export const meta = { 'ja-JP': '投稿の自動ウォッチをするか否か' } }), + + alwaysMarkNsfw: $.bool.optional.note({ + desc: { + 'ja-JP': 'アップロードするメディアをデフォルトで「閲覧注意」として設定するか' + } + }), } }; @@ -106,6 +112,7 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot; if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat; if (typeof ps.autoWatch == 'boolean') updates['settings.autoWatch'] = ps.autoWatch; + if (typeof ps.alwaysMarkNsfw == 'boolean') updates['settings.alwaysMarkNsfw'] = ps.alwaysMarkNsfw; if (ps.avatarId) { const avatar = await DriveFile.findOne({ diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index 828ebcbb94..666a6ca742 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -153,7 +153,7 @@ export default async function( isLink: boolean = false, url: string = null, uri: string = null, - sensitive = false + sensitive: boolean = null ): Promise { // Calc md5 hash const calcHash = new Promise((res, rej) => { @@ -329,7 +329,13 @@ export default async function( properties: properties, withoutChunks: isLink, isRemote: isLink, - isSensitive: sensitive + isSensitive: (sensitive !== null && sensitive !== undefined) + ? sensitive + : isLocalUser(user) + ? user.settings.alwaysMarkNsfw + ? true + : false + : false } as IMetadata; if (url !== null) {