From 655290f8a496fbda1aa66f3de1e33cdefe08aa00 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sat, 10 May 2025 13:04:03 -0400 Subject: add "is from local bubble instance" role condition --- packages/backend/src/core/RoleService.ts | 4 ++++ packages/backend/src/models/Role.ts | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'packages/backend/src') diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index e87c459d5c..039932b76d 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -262,6 +262,10 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { return user.host.toLowerCase() === value.host.toLowerCase(); } } + // Is the user from a local bubble instance + case 'fromBubbleInstance': { + return user.host != null && this.meta.bubbleInstances.includes(user.host); + } // サスペンド済みユーザである case 'isSuspended': { return user.isSuspended; diff --git a/packages/backend/src/models/Role.ts b/packages/backend/src/models/Role.ts index 2caf3e0bd3..f6e3050830 100644 --- a/packages/backend/src/models/Role.ts +++ b/packages/backend/src/models/Role.ts @@ -56,6 +56,13 @@ type CondFormulaValueIsFromInstance = { subdomains: boolean; }; +/** + * Is the user from a local bubble instance + */ +type CondFormulaValueFromBubbleInstance = { + type: 'fromBubbleInstance'; +}; + /** * 既に指定のマニュアルロールにアサインされている場合のみ成立とする */ @@ -234,6 +241,7 @@ export type RoleCondFormulaValue = { id: string } & ( CondFormulaValueIsLocal | CondFormulaValueIsRemote | CondFormulaValueIsFromInstance | + CondFormulaValueFromBubbleInstance | CondFormulaValueIsSuspended | CondFormulaValueIsLocked | CondFormulaValueIsBot | -- cgit v1.2.3-freya