Check if hook exists

This commit is contained in:
Mark Veidemanis 2022-11-03 15:59:27 +00:00
parent d319769fe0
commit 65f650f1ac
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 4 additions and 1 deletions

View File

@ -93,7 +93,10 @@ class HookAPI(APIView):
return HttpResponse("OK")
def get(self, request, hook_name):
try:
hook = Hook.objects.get(name=hook_name)
except Hook.DoesNotExist:
return HttpResponseBadRequest("Hook does not exist.")
return_data = {"name": hook.name, "hook": hook.hook, "hook_id": hook.id}
return HttpResponse(orjson.dumps(return_data), content_type="application/json")