From 655290f8a496fbda1aa66f3de1e33cdefe08aa00 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sat, 10 May 2025 13:04:03 -0400 Subject: [PATCH 1/2] add "is from local bubble instance" role condition --- locales/index.d.ts | 4 ++++ packages/backend/src/core/RoleService.ts | 4 ++++ packages/backend/src/models/Role.ts | 8 ++++++++ packages/frontend/src/pages/admin/RolesEditorFormula.vue | 1 + sharkey-locales/en-US.yml | 1 + 5 files changed, 18 insertions(+) diff --git a/locales/index.d.ts b/locales/index.d.ts index dc41c96a96..a165d0fd3e 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -7689,6 +7689,10 @@ export interface Locale extends ILocale { * Match subdomains */ "isFromInstanceSubdomains": string; + /** + * User is from a local bubble instance + */ + "fromBubbleInstance": string; /** * Has X or fewer local followers */ 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 | diff --git a/packages/frontend/src/pages/admin/RolesEditorFormula.vue b/packages/frontend/src/pages/admin/RolesEditorFormula.vue index 0f3afd5b22..b7375b0faf 100644 --- a/packages/frontend/src/pages/admin/RolesEditorFormula.vue +++ b/packages/frontend/src/pages/admin/RolesEditorFormula.vue @@ -10,6 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only + diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index 9232a7706c..c4f6d53f2f 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -245,6 +245,7 @@ _role: isFromInstance: "Is from a specific instance" isFromInstanceHost: "Hostname (case-insensitive)" isFromInstanceSubdomains: "Match subdomains" + fromBubbleInstance: "User is from a local bubble instance" localFollowersLessThanOrEq: "Has X or fewer local followers" localFollowersMoreThanOrEq: "Has X or more local followers" localFollowingLessThanOrEq: "Follows X or fewer local accounts" From 03d6655f9290857c018c8504c24520bfea8a1944 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 12 May 2025 13:31:48 -0400 Subject: [PATCH 2/2] fix wording of "User is from a bubble instance" --- locales/index.d.ts | 2 +- sharkey-locales/en-US.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index a165d0fd3e..8cb493bcf6 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -7690,7 +7690,7 @@ export interface Locale extends ILocale { */ "isFromInstanceSubdomains": string; /** - * User is from a local bubble instance + * User is from a bubble instance */ "fromBubbleInstance": string; /** diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index c4f6d53f2f..51903fb22b 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -245,7 +245,7 @@ _role: isFromInstance: "Is from a specific instance" isFromInstanceHost: "Hostname (case-insensitive)" isFromInstanceSubdomains: "Match subdomains" - fromBubbleInstance: "User is from a local bubble instance" + fromBubbleInstance: "User is from a bubble instance" localFollowersLessThanOrEq: "Has X or fewer local followers" localFollowersMoreThanOrEq: "Has X or more local followers" localFollowingLessThanOrEq: "Follows X or fewer local accounts"