enh: channel delete

This commit is contained in:
Timothy Jaeryang Baek
2024-12-22 23:15:29 -07:00
parent 7ad8918cd9
commit 4c756b5501
4 changed files with 73 additions and 1 deletions

View File

@@ -103,6 +103,29 @@ async def update_channel_by_id(
)
############################
# DeleteChannelById
############################
@router.delete("/{id}/delete", response_model=bool)
async def delete_channel_by_id(id: str, user=Depends(get_admin_user)):
channel = Channels.get_channel_by_id(id)
if not channel:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
)
try:
Channels.delete_channel_by_id(id)
return True
except Exception as e:
log.exception(e)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
)
############################
# GetChannelMessages
############################