feat/enh: show user count in channels

This commit is contained in:
Timothy Jaeryang Baek
2025-11-25 03:46:30 -05:00
parent a7ee36266a
commit 3b5710d0cd
4 changed files with 65 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ class ChannelModel(BaseModel):
class ChannelResponse(ChannelModel):
write_access: bool = False
user_count: Optional[int] = None
class ChannelForm(BaseModel):

View File

@@ -105,10 +105,13 @@ async def get_channel_by_id(id: str, user=Depends(get_verified_user)):
user.id, type="write", access_control=channel.access_control, strict=False
)
user_count = len(get_users_with_access("read", channel.access_control))
return ChannelResponse(
**{
**channel.model_dump(),
"write_access": write_access or user.role == "admin",
"user_count": user_count,
}
)