Fix: agent list owner filter not applied (#17410)

This commit is contained in:
euvre
2026-07-27 13:58:43 +08:00
committed by GitHub
parent 9bec8d12bb
commit 6cc862fc00
2 changed files with 19 additions and 26 deletions

View File

@@ -148,21 +148,18 @@ class UserCanvasService(CommonService):
cls.model.canvas_category,
cls.model.tags,
]
owner_filter = cls.model.user_id.in_(joined_tenant_ids) & ((cls.model.permission == TenantPermission.TEAM.value) | (cls.model.user_id == user_id))
if keywords:
agents = (
cls.model.select(*fields)
.join(User, on=(cls.model.user_id == User.id))
.where(
(((cls.model.user_id.in_(joined_tenant_ids)) & (cls.model.permission == TenantPermission.TEAM.value)) | (cls.model.user_id == user_id)),
owner_filter,
(fn.LOWER(cls.model.title).contains(keywords.lower())),
)
)
else:
agents = (
cls.model.select(*fields)
.join(User, on=(cls.model.user_id == User.id))
.where((((cls.model.user_id.in_(joined_tenant_ids)) & (cls.model.permission == TenantPermission.TEAM.value)) | (cls.model.user_id == user_id)))
)
agents = cls.model.select(*fields).join(User, on=(cls.model.user_id == User.id)).where(owner_filter)
if canvas_category:
agents = agents.where(cls.model.canvas_category == canvas_category)
if canvas_type: