moderation: add chat bans for groups/channels with web actions
All checks were successful
CI / test (push) Successful in 26s
All checks were successful
CI / test (push) Successful in 26s
This commit is contained in:
@@ -21,6 +21,7 @@ from app.chats.schemas import (
|
||||
)
|
||||
from app.chats.service import (
|
||||
add_chat_member_for_user,
|
||||
ban_chat_member_for_user,
|
||||
create_chat_for_user,
|
||||
create_chat_invite_link_for_user,
|
||||
clear_chat_for_user,
|
||||
@@ -39,6 +40,7 @@ from app.chats.service import (
|
||||
serialize_chats_for_user,
|
||||
set_chat_archived_for_user,
|
||||
set_chat_pinned_for_user,
|
||||
unban_chat_member_for_user,
|
||||
update_chat_member_role_for_user,
|
||||
update_chat_notification_settings_for_user,
|
||||
update_chat_profile_for_user,
|
||||
@@ -207,6 +209,29 @@ async def remove_chat_member(
|
||||
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||
|
||||
|
||||
@router.post("/{chat_id}/bans/{user_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def ban_chat_member(
|
||||
chat_id: int,
|
||||
user_id: int,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
) -> None:
|
||||
await ban_chat_member_for_user(db, chat_id=chat_id, actor_user_id=current_user.id, target_user_id=user_id)
|
||||
realtime_gateway.remove_chat_subscription(chat_id=chat_id, user_id=user_id)
|
||||
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||
|
||||
|
||||
@router.delete("/{chat_id}/bans/{user_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def unban_chat_member(
|
||||
chat_id: int,
|
||||
user_id: int,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
) -> None:
|
||||
await unban_chat_member_for_user(db, chat_id=chat_id, actor_user_id=current_user.id, target_user_id=user_id)
|
||||
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||
|
||||
|
||||
@router.post("/{chat_id}/leave", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def leave_chat(
|
||||
chat_id: int,
|
||||
|
||||
Reference in New Issue
Block a user