diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b100bae66b5..3fbc01fad13 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2108,6 +2108,7 @@ _role: driveCapacity: "ドライブ容量" maxFileSize: "アップロード可能な最大ファイルサイズ" maxFileSize_caption: "リバースプロキシやCDNなど、前段で別の設定値が存在する場合があります。" + maxFileSize_caption2: "サーバー全体の最大ファイルサイズ設定は {max} です。これより大きいファイルをアップロードできるようにするには、Misskeyの設定ファイルからこの設定を緩和してください。" alwaysMarkNsfw: "ファイルにNSFWを常に付与" canUpdateBioMedia: "アイコンとバナーの更新を許可" pinMax: "ノートのピン留めの最大数" diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index a57449157b4..54884646394 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -17,6 +17,7 @@ import type { } from '@/models/_.js'; import { MemoryKVCache, MemorySingleCache } from '@/misc/cache.js'; import type { MiUser } from '@/models/User.js'; +import type { Config } from '@/config.js'; import { DI } from '@/di-symbols.js'; import { bindThis } from '@/decorators.js'; import { CacheService } from '@/core/CacheService.js'; @@ -134,6 +135,9 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { constructor( private moduleRef: ModuleRef, + @Inject(DI.config) + private config: Config, + @Inject(DI.meta) private meta: MiMeta, @@ -378,7 +382,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { const roles = await this.getUserRoles(userId); function calc(name: T, aggregate: (values: RolePolicies[T][]) => RolePolicies[T]) { - if (roles.length === 0) return basePolicies[name]; + if (roles.length === 0) return aggregate([basePolicies[name]]); const policies = roles.map(role => role.policies[name] ?? { priority: 0, useDefault: true }); @@ -397,6 +401,8 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { return 'unavailable'; } + const serverMaxFileSizeMb = Math.floor(this.config.maxFileSize / (1024 * 1024)); + return { gtlAvailable: calc('gtlAvailable', vs => vs.some(v => v === true)), ltlAvailable: calc('ltlAvailable', vs => vs.some(v => v === true)), @@ -414,7 +420,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { canHideAds: calc('canHideAds', vs => vs.some(v => v === true)), canCreateChannel: calc('canCreateChannel', vs => vs.some(v => v === true)), driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)), - maxFileSizeMb: calc('maxFileSizeMb', vs => Math.max(...vs)), + maxFileSizeMb: calc('maxFileSizeMb', vs => Math.min(serverMaxFileSizeMb, Math.max(...vs))), alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)), canUpdateBioMedia: calc('canUpdateBioMedia', vs => vs.some(v => v === true)), pinLimit: calc('pinLimit', vs => Math.max(...vs)), diff --git a/packages/frontend/src/pages/admin/roles.policy-editor.vue b/packages/frontend/src/pages/admin/roles.policy-editor.vue index e1fa616df74..7c754c22365 100644 --- a/packages/frontend/src/pages/admin/roles.policy-editor.vue +++ b/packages/frontend/src/pages/admin/roles.policy-editor.vue @@ -188,6 +188,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -401,6 +402,7 @@ SPDX-License-Identifier: AGPL-3.0-only