fix(channel): enforce read-only for members and polish chat info
Some checks failed
CI / test (push) Failing after 26s
Some checks failed
CI / test (push) Failing after 26s
- block send/forward in channels for member role on backend - expose my_role in chat payload for client-side permissions - hide message composer for channel members and show read-only notice - hide members management sections for private/saved chats in info panel - return enriched chat detail via serialize_chat_for_user
This commit is contained in:
@@ -18,6 +18,10 @@ from app.users.repository import get_user_by_id
|
||||
|
||||
async def serialize_chat_for_user(db: AsyncSession, *, user_id: int, chat: Chat) -> ChatRead:
|
||||
display_title = chat.title
|
||||
my_role = None
|
||||
membership = await repository.get_chat_member(db, chat_id=chat.id, user_id=user_id)
|
||||
if membership:
|
||||
my_role = membership.role
|
||||
members_count: int | None = None
|
||||
online_count: int | None = None
|
||||
subscribers_count: int | None = None
|
||||
@@ -70,6 +74,7 @@ async def serialize_chat_for_user(db: AsyncSession, *, user_id: int, chat: Chat)
|
||||
"counterpart_username": counterpart_username,
|
||||
"counterpart_is_online": counterpart_is_online,
|
||||
"counterpart_last_seen_at": counterpart_last_seen_at,
|
||||
"my_role": my_role,
|
||||
"created_at": chat.created_at,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user