From 7f77517fc80f43253a33055b64d30e6d7b751dfd Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 19 Dec 2018 00:57:28 +0900 Subject: [PATCH] [Client] Resolve #3658 --- locales/ja-JP.yml | 2 ++ src/client/app/admin/views/drive.vue | 21 +++++++++++++++---- .../api/endpoints/drive/files/update.ts | 7 +++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index a6d1d1f858..1627c13717 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1197,6 +1197,8 @@ admin/views/drive.vue: remote: "リモート" delete: "削除" deleted: "削除しました" + mark-as-sensitive: "閲覧注意に設定" + unmark-as-sensitive: "閲覧注意を解除" admin/views/users.vue: operation: "操作" diff --git a/src/client/app/admin/views/drive.vue b/src/client/app/admin/views/drive.vue index c3a3a40644..0ebb50fb92 100644 --- a/src/client/app/admin/views/drive.vue +++ b/src/client/app/admin/views/drive.vue @@ -39,7 +39,11 @@
- {{ $t('delete') }} + + {{ $t('unmark-as-sensitive') }} + {{ $t('mark-as-sensitive') }} + {{ $t('delete') }} +
@@ -53,7 +57,7 @@ import Vue from 'vue'; import i18n from '../../i18n'; import { faCloud } from '@fortawesome/free-solid-svg-icons'; -import { faTrashAlt } from '@fortawesome/free-regular-svg-icons'; +import { faTrashAlt, faEye, faEyeSlash } from '@fortawesome/free-regular-svg-icons'; export default Vue.extend({ i18n: i18n('admin/views/drive.vue'), @@ -66,7 +70,7 @@ export default Vue.extend({ offset: 0, files: [], existMore: false, - faCloud, faTrashAlt + faCloud, faTrashAlt, faEye, faEyeSlash }; }, @@ -132,7 +136,16 @@ export default Vue.extend({ text: e.toString() }); }); - } + }, + + toggleSensitive(file: any) { + this.$root.api('drive/files/update', { + fileId: file.id, + isSensitive: !file.isSensitive + }); + + file.isSensitive = !file.isSensitive; + }, } }); diff --git a/src/server/api/endpoints/drive/files/update.ts b/src/server/api/endpoints/drive/files/update.ts index 7f9eb7bad3..a17ff2bf34 100644 --- a/src/server/api/endpoints/drive/files/update.ts +++ b/src/server/api/endpoints/drive/files/update.ts @@ -57,14 +57,17 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { // Fetch file const file = await DriveFile .findOne({ - _id: ps.fileId, - 'metadata.userId': user._id + _id: ps.fileId }); if (file === null) { return rej('file-not-found'); } + if (!user.isAdmin && !user.isModerator && !file.metadata.userId.equals(user._id)) { + return rej('access denied'); + } + if (ps.name) file.filename = ps.name; if (ps.isSensitive !== undefined) file.metadata.isSensitive = ps.isSensitive;