mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-25 12:01:04 +02:00
Merge remote-tracking branch 'origin/main' into fix/org-scoped-access
# Conflicts: # api/routes/agent_stream.py # api/routes/telephony.py # api/routes/webrtc_signaling.py # docs/api-reference/openapi.json # sdk/python/src/dograh_sdk/_generated_models.py
This commit is contained in:
commit
d22c073cb5
38 changed files with 2332 additions and 471 deletions
|
|
@ -9,6 +9,7 @@ from api.db.base_client import BaseDBClient
|
|||
from api.db.models import (
|
||||
APIKeyModel,
|
||||
OrganizationModel,
|
||||
UserModel,
|
||||
organization_users_association,
|
||||
)
|
||||
from api.utils.api_key import generate_api_key
|
||||
|
|
@ -25,6 +26,22 @@ class OrganizationClient(BaseDBClient):
|
|||
)
|
||||
return result.scalars().first()
|
||||
|
||||
async def get_organization_users(self, organization_id: int) -> list[UserModel]:
|
||||
"""Get all users linked to an organization (many-to-many)."""
|
||||
async with self.async_session() as session:
|
||||
result = await session.execute(
|
||||
select(UserModel)
|
||||
.join(
|
||||
organization_users_association,
|
||||
organization_users_association.c.user_id == UserModel.id,
|
||||
)
|
||||
.where(
|
||||
organization_users_association.c.organization_id == organization_id
|
||||
)
|
||||
.order_by(UserModel.id)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_or_create_organization_by_provider_id(
|
||||
self, org_provider_id: str, user_id: int
|
||||
) -> tuple[OrganizationModel, bool]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue