Skip to content

Commit a1ae6aa

Browse files
committed
review feedback
1 parent c894e19 commit a1ae6aa

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ worker:
5858
test:
5959
$(TEST_CMD) -s -v
6060

61-
test_:
61+
test_last_failed:
6262
$(TEST_CMD) -s -v --last-failed
6363

64+
test_: test_last_failed
65+
6466
test/k:
6567
$(TEST_CMD) -s -v -k $(K)
6668

intbot/core/endpoints/webhooks.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def internal_webhook_endpoint(request):
2323
content=json.loads(request.body),
2424
extra={},
2525
)
26+
# Schedule a task for the worker to process the webhook outside of
27+
# request/response cycle.
2628
process_webhook.enqueue(str(wh.uuid))
2729

2830
return JsonResponse({"status": "created", "guid": wh.uuid})
@@ -45,22 +47,24 @@ def verify_internal_webhook(request):
4547
@csrf_exempt
4648
def github_webhook_endpoint(request):
4749
if request.method == "POST":
48-
github_headers = {
49-
k: v for k, v in request.headers.items() if k.startswith("X-Github")
50-
}
51-
5250
try:
5351
signature = verify_github_signature(request)
5452
except ValueError as e:
5553
return HttpResponseForbidden(e)
5654

55+
github_headers = {
56+
k: v for k, v in request.headers.items() if k.startswith("X-Github")
57+
}
58+
5759
wh = Webhook.objects.create(
5860
source="github",
5961
meta=github_headers,
6062
signature=signature,
6163
content=json.loads(request.body),
6264
extra={},
6365
)
66+
# Schedule a task for the worker to process the webhook outside of
67+
# request/response cycle.
6468
process_webhook.enqueue(str(wh.uuid))
6569
return JsonResponse({"status": "created", "guid": wh.uuid})
6670

@@ -92,26 +96,27 @@ def verify_github_signature(request) -> str:
9296
@csrf_exempt
9397
def zammad_webhook_endpoint(request):
9498
if request.method == "POST":
95-
zammad_headers = {
96-
k: v for k, v in request.headers.items() if k.startswith("X-Zammad")
97-
}
98-
9999
try:
100100
signature = verify_zammad_signature(request)
101101
except ValueError as e:
102102
return HttpResponseForbidden(e)
103103

104+
zammad_headers = {
105+
k: v for k, v in request.headers.items() if k.startswith("X-Zammad")
106+
}
107+
104108
wh = Webhook.objects.create(
105109
source="zammad",
106110
meta=zammad_headers,
107111
signature=signature,
108112
content=json.loads(request.body),
109113
extra={},
110114
)
115+
# Schedule a task for the worker to process the webhook outside of
116+
# request/response cycle.
111117
process_webhook.enqueue(str(wh.uuid))
112118
return JsonResponse({"status": "created", "guid": wh.uuid})
113119

114-
115120
return HttpResponseNotAllowed("Only POST")
116121

117122

0 commit comments

Comments
 (0)