[misc] Fix all 204 responses

This commit is contained in:
Cathy Hu 2020-09-11 02:58:39 +02:00
parent 96b1900b46
commit 3025d8b05a
6 changed files with 10 additions and 0 deletions

View file

@ -171,6 +171,7 @@ async def email_delete(email=Depends(get_email)):
:param hood: Hood the Email bot belongs to.
"""
await email.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.post(
@ -257,6 +258,7 @@ async def email_unsubscribe(token, hood=Depends(get_hood_unauthorized)):
hood=payload['hood'], email=payload['email']
).get()
await subscriber.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)
except NoMatch:
return HTTPException(status_code=status.HTTP_404_NOT_FOUND)
except exceptions.CryptoError:

View file

@ -87,6 +87,7 @@ async def telegram_delete(telegram=Depends(get_telegram)):
for user in await TelegramUser.objects.filter(bot=telegram).all():
await user.delete()
await telegram.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.post(

View file

@ -74,6 +74,7 @@ async def twitter_read(twitter=Depends(get_twitter)):
async def twitter_delete(twitter=Depends(get_twitter)):
spawner.stop(twitter)
await twitter.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.get(

View file

@ -106,6 +106,7 @@ async def hood_update(values: BodyHood, hood=Depends(get_hood)):
- **landingpage**: New Markdown formatted description of the hood
"""
await hood.update(**values.__dict__)
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.delete(
@ -124,3 +125,4 @@ async def hood_delete(hood=Depends(get_hood)):
for relation in await AdminHoodRelation.objects.filter(hood=hood).all():
await relation.delete()
await hood.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)

View file

@ -88,6 +88,7 @@ async def badword_update(values: BodyBadWord, badword=Depends(get_badword)):
- **pattern**: Regular expression which is used to match a badword
"""
await badword.update(**values.__dict__)
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.delete(
@ -98,3 +99,4 @@ async def badword_update(values: BodyBadWord, badword=Depends(get_badword)):
async def badword_delete(badword=Depends(get_badword)):
""" Deletes badword with id **badword_id** for hood with id **hood_id**. """
await badword.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)

View file

@ -89,6 +89,7 @@ async def trigger_update(values: BodyTrigger, trigger=Depends(get_trigger)):
- **pattern**: Regular expression which is used to match a trigger
"""
await trigger.update(**values.__dict__)
return Response(status_code=status.HTTP_204_NO_CONTENT)
@router.delete(
@ -99,3 +100,4 @@ async def trigger_update(values: BodyTrigger, trigger=Depends(get_trigger)):
async def trigger_delete(trigger=Depends(get_trigger)):
""" Deletes trigger with id **trigger_id** for hood with id **hood_id**. """
await trigger.delete()
return Response(status_code=status.HTTP_204_NO_CONTENT)