summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/RoleService.ts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2025-04-07 19:09:11 +0900
committerGitHub <noreply@github.com>2025-04-07 19:09:11 +0900
commit9d3f3264fdd059f47537da48fd125cdd2f4bad1e (patch)
treededbf1433d0e003465b37e805519c5635b135466 /packages/backend/src/core/RoleService.ts
parentUpdate CHANGELOG.md (diff)
downloadsharkey-9d3f3264fdd059f47537da48fd125cdd2f4bad1e.tar.gz
sharkey-9d3f3264fdd059f47537da48fd125cdd2f4bad1e.tar.bz2
sharkey-9d3f3264fdd059f47537da48fd125cdd2f4bad1e.zip
enhance: チャットの閲覧を無効化できるように (#15765)
* enhance: チャットの閲覧を無効化できるように * fix * fix * fix * readonlyの説明を追加 * enhance: チャットが無効な場合はチャット関連の設定も隠すように * fix * refactor: ChatServiceからApiに関するドメイン知識を排除
Diffstat (limited to 'packages/backend/src/core/RoleService.ts')
-rw-r--r--packages/backend/src/core/RoleService.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts
index 0a2659ee32..601959cc96 100644
--- a/packages/backend/src/core/RoleService.ts
+++ b/packages/backend/src/core/RoleService.ts
@@ -63,7 +63,7 @@ export type RolePolicies = {
canImportFollowing: boolean;
canImportMuting: boolean;
canImportUserLists: boolean;
- canChat: boolean;
+ chatAvailability: 'available' | 'readonly' | 'unavailable';
};
export const DEFAULT_POLICIES: RolePolicies = {
@@ -98,7 +98,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
canImportFollowing: true,
canImportMuting: true,
canImportUserLists: true,
- canChat: true,
+ chatAvailability: 'available',
};
@Injectable()
@@ -370,6 +370,12 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
return aggregate(policies.map(policy => policy.useDefault ? basePolicies[name] : policy.value));
}
+ function aggregateChatAvailability(vs: RolePolicies['chatAvailability'][]) {
+ if (vs.some(v => v === 'available')) return 'available';
+ if (vs.some(v => v === 'readonly')) return 'readonly';
+ return 'unavailable';
+ }
+
return {
gtlAvailable: calc('gtlAvailable', vs => vs.some(v => v === true)),
ltlAvailable: calc('ltlAvailable', vs => vs.some(v => v === true)),
@@ -402,7 +408,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
canImportFollowing: calc('canImportFollowing', vs => vs.some(v => v === true)),
canImportMuting: calc('canImportMuting', vs => vs.some(v => v === true)),
canImportUserLists: calc('canImportUserLists', vs => vs.some(v => v === true)),
- canChat: calc('canChat', vs => vs.some(v => v === true)),
+ chatAvailability: calc('chatAvailability', aggregateChatAvailability),
};
}