webhooks: add webhook delete impl

This commit is contained in:
Luna 2019-03-17 17:39:59 -03:00
parent d29fa2e1f3
commit 8360638356
1 changed files with 19 additions and 2 deletions

View File

@ -232,14 +232,31 @@ async def modify_webhook_tokened(webhook_id, webhook_token):
return jsonify(await get_webhook(webhook_id, secure=False)) return jsonify(await get_webhook(webhook_id, secure=False))
async def delete_webhook(webhook_id: int):
"""Delete a webhook."""
res = await app.db.execute("""
DELETE FROM webhooks
WHERE id = $1
""", webhook_id)
if res.lower() == 'delete 0':
raise WebhookNotFound()
@bp.route('/webhooks/<int:webhook_id>', methods=['DELETE']) @bp.route('/webhooks/<int:webhook_id>', methods=['DELETE'])
async def del_webhook(webhook_id): async def del_webhook(webhook_id):
pass """Delete a webhook."""
await _webhook_check_fw(webhook_id)
await delete_webhook(webhook_id)
return '', 204
@bp.route('/webhooks/<int:webhook_id>/<webhook_token>', methods=['DELETE']) @bp.route('/webhooks/<int:webhook_id>/<webhook_token>', methods=['DELETE'])
async def del_webhook_tokened(webhook_id, webhook_token): async def del_webhook_tokened(webhook_id, webhook_token):
pass """Delete a webhook, with its token."""
await webhook_token_check(webhook_id, webhook_token)
await delete_webhook(webhook_id)
return '', 204
@bp.route('/webhooks/<int:webhook_id>/<webhook_token>', methods=['POST']) @bp.route('/webhooks/<int:webhook_id>/<webhook_token>', methods=['POST'])