feat(libs): Introduce extract_tenant_id (#22086)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN-
2025-07-09 17:45:56 +08:00
committed by GitHub
parent 1885426421
commit 4cb50f1809
8 changed files with 106 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ from core.variables import utils as variable_utils
from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID
from core.workflow.nodes.enums import NodeType
from factories.variable_factory import TypeMismatchError, build_segment_with_type
from libs.helper import extract_tenant_id
from ._workflow_exc import NodeNotFoundError, WorkflowDataError
@@ -352,12 +353,7 @@ class Workflow(Base):
self._environment_variables = "{}"
# Get tenant_id from current_user (Account or EndUser)
if isinstance(current_user, Account):
# Account user
tenant_id = current_user.current_tenant_id
else:
# EndUser
tenant_id = current_user.tenant_id
tenant_id = extract_tenant_id(current_user)
if not tenant_id:
return []
@@ -384,12 +380,7 @@ class Workflow(Base):
return
# Get tenant_id from current_user (Account or EndUser)
if isinstance(current_user, Account):
# Account user
tenant_id = current_user.current_tenant_id
else:
# EndUser
tenant_id = current_user.tenant_id
tenant_id = extract_tenant_id(current_user)
if not tenant_id:
self._environment_variables = "{}"