From dd77a6194e4fff8f581824a0caa82c27f7bb80b4 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 11 Jan 2019 08:10:39 +0900 Subject: [PATCH] Hide NSFW in Photos (#3875) --- .../desktop/views/pages/deck/deck.user-column.vue | 1 + .../app/desktop/views/pages/user/user.photos.vue | 2 ++ .../app/mobile/views/pages/user/home.photos.vue | 1 + src/server/api/endpoints/users/notes.ts | 14 ++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/src/client/app/desktop/views/pages/deck/deck.user-column.vue b/src/client/app/desktop/views/pages/deck/deck.user-column.vue index 65feea969..c2132450c 100644 --- a/src/client/app/desktop/views/pages/deck/deck.user-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.user-column.vue @@ -169,6 +169,7 @@ export default Vue.extend({ this.$root.api('users/notes', { userId: this.user.id, fileType: image, + excludeNsfw: !this.$store.state.device.alwaysShowNsfw, limit: 9, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { diff --git a/src/client/app/desktop/views/pages/user/user.photos.vue b/src/client/app/desktop/views/pages/user/user.photos.vue index b147a6ab3..cd8853e0b 100644 --- a/src/client/app/desktop/views/pages/user/user.photos.vue +++ b/src/client/app/desktop/views/pages/user/user.photos.vue @@ -29,9 +29,11 @@ export default Vue.extend({ 'image/png', 'image/gif' ]; + this.$root.api('users/notes', { userId: this.user.id, fileType: image, + excludeNsfw: !this.$store.state.device.alwaysShowNsfw, limit: 9, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { diff --git a/src/client/app/mobile/views/pages/user/home.photos.vue b/src/client/app/mobile/views/pages/user/home.photos.vue index 95b867a51..cd6d0e674 100644 --- a/src/client/app/mobile/views/pages/user/home.photos.vue +++ b/src/client/app/mobile/views/pages/user/home.photos.vue @@ -34,6 +34,7 @@ export default Vue.extend({ this.$root.api('users/notes', { userId: this.user.id, fileType: image, + excludeNsfw: !this.$store.state.device.alwaysShowNsfw, limit: 9, untilDate: new Date().getTime() + 1000 * 86400 * 365 }).then(notes => { diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index 6c336683a..7d73fde1c 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -124,6 +124,14 @@ export const meta = { 'ja-JP': '指定された種類のファイルが添付された投稿のみを取得します' } }, + + excludeNsfw: { + validator: $.bool.optional, + default: false, + desc: { + 'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)' + } + }, } }; @@ -233,6 +241,12 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { query['_files.contentType'] = { $in: ps.fileType }; + + if (ps.excludeNsfw) { + query['_files.metadata.isSensitive'] = { + $ne: true + }; + } } //#endregion