mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-09 04:40:57 +00:00
* fix(cloud): show owner model balance and enforce single owner * fix(migrations): create owner index idempotently --------- Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
This commit is contained in:
@@ -19,7 +19,6 @@ class Permission(enum.StrEnum):
|
||||
WORKSPACE_VIEW = 'workspace.view'
|
||||
WORKSPACE_UPDATE = 'workspace.update'
|
||||
WORKSPACE_DELETE = 'workspace.delete'
|
||||
OWNER_TRANSFER = 'owner.transfer'
|
||||
MEMBER_VIEW = 'member.view'
|
||||
MEMBER_INVITE = 'member.invite'
|
||||
MEMBER_UPDATE_ROLE = 'member.update_role'
|
||||
@@ -49,7 +48,6 @@ _ROLE_PERMISSIONS: typing.Final = types.MappingProxyType(
|
||||
if permission
|
||||
not in {
|
||||
Permission.WORKSPACE_DELETE,
|
||||
Permission.OWNER_TRANSFER,
|
||||
Permission.BILLING_LINK_MANAGE,
|
||||
}
|
||||
),
|
||||
|
||||
@@ -62,7 +62,6 @@ class AuthType(enum.Enum):
|
||||
|
||||
_SUPPORT_ADMIN_DENIED_PERMISSIONS = frozenset(
|
||||
{
|
||||
Permission.OWNER_TRANSFER.value,
|
||||
Permission.MEMBER_VIEW.value,
|
||||
Permission.MEMBER_INVITE.value,
|
||||
Permission.MEMBER_UPDATE_ROLE.value,
|
||||
|
||||
@@ -291,11 +291,19 @@ class UserRouterGroup(group.RouterGroup):
|
||||
# Workspace owner is already bound even when this Core has no local OAuth
|
||||
# token row (model billing uses the owner's control-plane API key).
|
||||
owner_space_bound = cloud_mode or owner_has_local_space_credentials
|
||||
credits = (
|
||||
await self.ap.space_service.get_credits(owner.user)
|
||||
if owner is not None and owner.space_account_uuid
|
||||
else None
|
||||
)
|
||||
if cloud_mode:
|
||||
catalog_service = getattr(self.ap, 'cloud_model_catalog_service', None)
|
||||
credits = (
|
||||
catalog_service.get_workspace_credits(access.workspace.uuid)
|
||||
if catalog_service is not None
|
||||
else None
|
||||
)
|
||||
else:
|
||||
credits = (
|
||||
await self.ap.space_service.get_credits(owner.user)
|
||||
if owner is not None and owner.space_account_uuid
|
||||
else None
|
||||
)
|
||||
return self.success(
|
||||
data={
|
||||
'credits': credits,
|
||||
|
||||
Reference in New Issue
Block a user