Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,7 @@ _role:
driveCapacity: "ドライブ容量"
maxFileSize: "アップロード可能な最大ファイルサイズ"
maxFileSize_caption: "リバースプロキシやCDNなど、前段で別の設定値が存在する場合があります。"
maxFileSize_caption2: "サーバー全体の最大ファイルサイズ設定は {max} です。これより大きいファイルをアップロードできるようにするには、Misskeyの設定ファイルからこの設定を緩和してください。"
alwaysMarkNsfw: "ファイルにNSFWを常に付与"
canUpdateBioMedia: "アイコンとバナーの更新を許可"
pinMax: "ノートのピン留めの最大数"
Expand Down
10 changes: 8 additions & 2 deletions packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -378,7 +382,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
const roles = await this.getUserRoles(userId);

function calc<T extends keyof RolePolicies>(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 });

Expand All @@ -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)),
Expand All @@ -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)),
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/pages/admin/roles.policy-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="valuesModel.maxFileSizeMb" type="number" :disabled="disabled">
<template #suffix>MB</template>
<template #caption>
<div>{{ i18n.tsx._role._options.maxFileSize_caption2({ max: `${Math.floor(instance.maxFileSize / (1024 * 1024))}MB` }) }}</div>
<div><i class="ti ti-alert-triangle" style="color: var(--MI_THEME-warn);"></i> {{ i18n.ts._role._options.maxFileSize_caption }}</div>
</template>
</MkInput>
Expand Down Expand Up @@ -401,6 +402,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts">
import * as Misskey from 'misskey-js';
import { instance } from '@/instance.js';

export type PolicyMeta = {
useDefault: boolean;
Expand Down
4 changes: 4 additions & 0 deletions packages/i18n/src/autogen/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8121,6 +8121,10 @@ export interface Locale extends ILocale {
* リバースプロキシやCDNなど、前段で別の設定値が存在する場合があります。
*/
"maxFileSize_caption": string;
/**
* サーバー全体の最大ファイルサイズ設定は {max} です。これより大きいファイルをアップロードできるようにするには、Misskeyの設定ファイルからこの設定を緩和してください。
*/
"maxFileSize_caption2": ParameterizedString<"max">;
/**
* ファイルにNSFWを常に付与
*/
Expand Down
Loading