feat(moderation): add chat bans list endpoint with admin access checks
Some checks are pending
CI / test (push) Has started running
Some checks are pending
CI / test (push) Has started running
This commit is contained in:
@@ -3,6 +3,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.auth.service import get_current_user
|
||||
from app.chats.schemas import (
|
||||
ChatBanRead,
|
||||
ChatCreateRequest,
|
||||
ChatDetailRead,
|
||||
ChatDiscoverRead,
|
||||
@@ -38,6 +39,7 @@ from app.chats.service import (
|
||||
leave_chat_for_user,
|
||||
pin_chat_message_for_user,
|
||||
remove_chat_member_for_user,
|
||||
list_chat_bans_for_user,
|
||||
serialize_chat_for_user,
|
||||
serialize_chats_for_user,
|
||||
set_chat_archived_for_user,
|
||||
@@ -226,6 +228,15 @@ async def ban_chat_member(
|
||||
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||
|
||||
|
||||
@router.get("/{chat_id}/bans", response_model=list[ChatBanRead])
|
||||
async def list_chat_bans(
|
||||
chat_id: int,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
) -> list[ChatBanRead]:
|
||||
return await list_chat_bans_for_user(db, chat_id=chat_id, actor_user_id=current_user.id)
|
||||
|
||||
|
||||
@router.delete("/{chat_id}/bans/{user_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def unban_chat_member(
|
||||
chat_id: int,
|
||||
|
||||
Reference in New Issue
Block a user