fix(channel): member delete acts as leave; add coverage and docs
All checks were successful
CI / test (push) Successful in 42s
All checks were successful
CI / test (push) Successful in 42s
This commit is contained in:
@@ -571,6 +571,12 @@ async def delete_chat_for_user(db: AsyncSession, *, chat_id: int, user_id: int,
|
||||
if chat.is_saved:
|
||||
await clear_chat_for_user(db, chat_id=chat_id, user_id=user_id)
|
||||
return
|
||||
if chat.type == ChatType.CHANNEL and membership.role == ChatMemberRole.MEMBER:
|
||||
if payload.for_all:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Insufficient permissions")
|
||||
await repository.delete_chat_member(db, membership)
|
||||
await db.commit()
|
||||
return
|
||||
delete_for_all = (payload.for_all and not chat.is_saved) or chat.type == ChatType.CHANNEL
|
||||
if delete_for_all:
|
||||
if chat.type in {ChatType.GROUP, ChatType.CHANNEL} and membership.role not in {ChatMemberRole.OWNER, ChatMemberRole.ADMIN}:
|
||||
|
||||
Reference in New Issue
Block a user