From b2504568145cccfb42999fc6ad6413151d555a1e Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 13 Jan 2023 14:58:27 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E7=B5=B5?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=81=AE=E7=AE=A1=E7=90=86=E3=82=92=E6=A8=A9?= =?UTF-8?q?=E9=99=90=E3=82=92=E6=8C=81=E3=81=A4=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E8=A1=8C=E3=81=88=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #9542 --- CHANGELOG.md | 1 + locales/ja-JP.yml | 2 ++ packages/backend/src/core/RoleService.ts | 3 +++ .../endpoints/admin/emoji/add-aliases-bulk.ts | 2 +- .../src/server/api/endpoints/admin/emoji/add.ts | 2 +- .../src/server/api/endpoints/admin/emoji/copy.ts | 2 +- .../api/endpoints/admin/emoji/delete-bulk.ts | 2 +- .../server/api/endpoints/admin/emoji/delete.ts | 2 +- .../api/endpoints/admin/emoji/import-zip.ts | 2 +- .../api/endpoints/admin/emoji/list-remote.ts | 2 +- .../src/server/api/endpoints/admin/emoji/list.ts | 2 +- .../endpoints/admin/emoji/remove-aliases-bulk.ts | 2 +- .../endpoints/admin/emoji/set-aliases-bulk.ts | 2 +- .../endpoints/admin/emoji/set-category-bulk.ts | 2 +- .../server/api/endpoints/admin/emoji/update.ts | 2 +- .../frontend/src/pages/admin/roles.editor.vue | 16 ++++++++++++++++ packages/frontend/src/pages/admin/roles.vue | 10 ++++++++++ .../emojis.vue => custom-emojis-manager.vue} | 3 +-- .../src/pages/{admin => }/emoji-edit-dialog.vue | 0 packages/frontend/src/router.ts | 5 ++++- packages/frontend/src/ui/_common_/common.ts | 7 ++++++- 21 files changed, 55 insertions(+), 16 deletions(-) rename packages/frontend/src/pages/{admin/emojis.vue => custom-emojis-manager.vue} (98%) rename packages/frontend/src/pages/{admin => }/emoji-edit-dialog.vue (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d612bd69..d9e1346b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ You should also include the user name that made the change. - AVIF support @tamaina - Add Cloudflare Turnstile CAPTCHA support @CyberRex0 - 非モデレーターでも、権限を持つロールをアサインされたユーザーはインスタンスの招待コードを発行できるように +- 非モデレーターでも、権限を持つロールをアサインされたユーザーはカスタム絵文字の追加、編集、削除を行えるように - Server: signToActivityPubGet is set to true by default @syuilo - Server: improve syslog performance @syuilo - Server: Use undici instead of node-fetch and got @tamaina diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 4a1a2d68e..934ee0615 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -931,6 +931,7 @@ undefined: "未定義" assign: "アサイン" unassign: "アサインを解除" color: "色" +manageCustomEmojis: "カスタム絵文字の管理" _role: new: "ロールの作成" @@ -958,6 +959,7 @@ _role: ltlAvailable: "ローカルタイムラインの閲覧" canPublicNote: "パブリック投稿の許可" canInvite: "インスタンス招待コードの発行" + canManageCustomEmojis: "カスタム絵文字の管理" driveCapacity: "ドライブ容量" antennaMax: "アンテナの作成可能数" _condition: diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index 78524c833..15ba90080 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -17,6 +17,7 @@ export type RoleOptions = { ltlAvailable: boolean; canPublicNote: boolean; canInvite: boolean; + canManageCustomEmojis: boolean; driveCapacityMb: number; antennaLimit: number; }; @@ -26,6 +27,7 @@ export const DEFAULT_ROLE: RoleOptions = { ltlAvailable: true, canPublicNote: true, canInvite: false, + canManageCustomEmojis: false, driveCapacityMb: 100, antennaLimit: 5, }; @@ -182,6 +184,7 @@ export class RoleService implements OnApplicationShutdown { ltlAvailable: getOptionValues('ltlAvailable').some(x => x === true), canPublicNote: getOptionValues('canPublicNote').some(x => x === true), canInvite: getOptionValues('canInvite').some(x => x === true), + canManageCustomEmojis: getOptionValues('canManageCustomEmojis').some(x => x === true), driveCapacityMb: Math.max(...getOptionValues('driveCapacityMb')), antennaLimit: Math.max(...getOptionValues('antennaLimit')), }; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts index 7c24e8baa..d114fd3d5 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts @@ -8,7 +8,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index c4e1987d7..52ccb7444 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -14,7 +14,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', errors: { noSuchFile: { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index 2cdd9c36b..4d1fdd989 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -14,7 +14,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', errors: { noSuchEmoji: { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts index 8b2031e6d..27aa4fb1b 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts @@ -9,7 +9,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts index dd7cd4ced..253124656 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts @@ -10,7 +10,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', errors: { noSuchEmoji: { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts index 6fe492cb7..15f468c18 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts @@ -5,7 +5,7 @@ import { QueueService } from '@/core/QueueService.js'; export const meta = { secure: true, requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts index 08ffc73fe..131c9ef22 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts @@ -11,7 +11,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', res: { type: 'array', diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts index 6bcd4973d..ef2bc936c 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts @@ -11,7 +11,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', res: { type: 'array', diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts index 99512a26b..a70cd8d78 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts @@ -8,7 +8,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts index 697999cc7..b33e5662b 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts @@ -8,7 +8,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts index 00a5b162b..05834bc57 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts @@ -8,7 +8,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index c576950ac..19645cb51 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -9,7 +9,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireRoleOption: 'canManageCustomEmojis', errors: { noSuchEmoji: { diff --git a/packages/frontend/src/pages/admin/roles.editor.vue b/packages/frontend/src/pages/admin/roles.editor.vue index 1d83ae324..b66c967e6 100644 --- a/packages/frontend/src/pages/admin/roles.editor.vue +++ b/packages/frontend/src/pages/admin/roles.editor.vue @@ -90,6 +90,19 @@ + + + +
+ + + + + + +
+
+ @@ -175,6 +188,8 @@ let options_canPublicNote_useDefault = $ref(role?.options?.canPublicNote?.useDef let options_canPublicNote_value = $ref(role?.options?.canPublicNote?.value ?? false); let options_canInvite_useDefault = $ref(role?.options?.canInvite?.useDefault ?? true); let options_canInvite_value = $ref(role?.options?.canInvite?.value ?? false); +let options_canManageCustomEmojis_useDefault = $ref(role?.options?.canManageCustomEmojis?.useDefault ?? true); +let options_canManageCustomEmojis_value = $ref(role?.options?.canManageCustomEmojis?.value ?? false); let options_driveCapacityMb_useDefault = $ref(role?.options?.driveCapacityMb?.useDefault ?? true); let options_driveCapacityMb_value = $ref(role?.options?.driveCapacityMb?.value ?? 0); let options_antennaLimit_useDefault = $ref(role?.options?.antennaLimit?.useDefault ?? true); @@ -192,6 +207,7 @@ function getOptions() { ltlAvailable: { useDefault: options_ltlAvailable_useDefault, value: options_ltlAvailable_value }, canPublicNote: { useDefault: options_canPublicNote_useDefault, value: options_canPublicNote_value }, canInvite: { useDefault: options_canInvite_useDefault, value: options_canInvite_value }, + canManageCustomEmojis: { useDefault: options_canManageCustomEmojis_useDefault, value: options_canManageCustomEmojis_value }, driveCapacityMb: { useDefault: options_driveCapacityMb_useDefault, value: options_driveCapacityMb_value }, antennaLimit: { useDefault: options_antennaLimit_useDefault, value: options_antennaLimit_value }, }; diff --git a/packages/frontend/src/pages/admin/roles.vue b/packages/frontend/src/pages/admin/roles.vue index 6495074bb..16c12f992 100644 --- a/packages/frontend/src/pages/admin/roles.vue +++ b/packages/frontend/src/pages/admin/roles.vue @@ -40,6 +40,14 @@ + + + + + + + + @@ -90,6 +98,7 @@ let options_gtlAvailable = $ref(instance.baseRole.gtlAvailable); let options_ltlAvailable = $ref(instance.baseRole.ltlAvailable); let options_canPublicNote = $ref(instance.baseRole.canPublicNote); let options_canInvite = $ref(instance.baseRole.canInvite); +let options_canManageCustomEmojis = $ref(instance.baseRole.canManageCustomEmojis); let options_driveCapacityMb = $ref(instance.baseRole.driveCapacityMb); let options_antennaLimit = $ref(instance.baseRole.antennaLimit); @@ -100,6 +109,7 @@ async function updateBaseRole() { ltlAvailable: options_ltlAvailable, canPublicNote: options_canPublicNote, canInvite: options_canInvite, + canManageCustomEmojis: options_canManageCustomEmojis, driveCapacityMb: options_driveCapacityMb, antennaLimit: options_antennaLimit, }, diff --git a/packages/frontend/src/pages/admin/emojis.vue b/packages/frontend/src/pages/custom-emojis-manager.vue similarity index 98% rename from packages/frontend/src/pages/admin/emojis.vue rename to packages/frontend/src/pages/custom-emojis-manager.vue index 49f130d75..87d205ed7 100644 --- a/packages/frontend/src/pages/admin/emojis.vue +++ b/packages/frontend/src/pages/custom-emojis-manager.vue @@ -1,7 +1,7 @@