@@ -23,6 +23,8 @@ def internal_webhook_endpoint(request):
23
23
content = json .loads (request .body ),
24
24
extra = {},
25
25
)
26
+ # Schedule a task for the worker to process the webhook outside of
27
+ # request/response cycle.
26
28
process_webhook .enqueue (str (wh .uuid ))
27
29
28
30
return JsonResponse ({"status" : "created" , "guid" : wh .uuid })
@@ -45,22 +47,24 @@ def verify_internal_webhook(request):
45
47
@csrf_exempt
46
48
def github_webhook_endpoint (request ):
47
49
if request .method == "POST" :
48
- github_headers = {
49
- k : v for k , v in request .headers .items () if k .startswith ("X-Github" )
50
- }
51
-
52
50
try :
53
51
signature = verify_github_signature (request )
54
52
except ValueError as e :
55
53
return HttpResponseForbidden (e )
56
54
55
+ github_headers = {
56
+ k : v for k , v in request .headers .items () if k .startswith ("X-Github" )
57
+ }
58
+
57
59
wh = Webhook .objects .create (
58
60
source = "github" ,
59
61
meta = github_headers ,
60
62
signature = signature ,
61
63
content = json .loads (request .body ),
62
64
extra = {},
63
65
)
66
+ # Schedule a task for the worker to process the webhook outside of
67
+ # request/response cycle.
64
68
process_webhook .enqueue (str (wh .uuid ))
65
69
return JsonResponse ({"status" : "created" , "guid" : wh .uuid })
66
70
@@ -92,26 +96,27 @@ def verify_github_signature(request) -> str:
92
96
@csrf_exempt
93
97
def zammad_webhook_endpoint (request ):
94
98
if request .method == "POST" :
95
- zammad_headers = {
96
- k : v for k , v in request .headers .items () if k .startswith ("X-Zammad" )
97
- }
98
-
99
99
try :
100
100
signature = verify_zammad_signature (request )
101
101
except ValueError as e :
102
102
return HttpResponseForbidden (e )
103
103
104
+ zammad_headers = {
105
+ k : v for k , v in request .headers .items () if k .startswith ("X-Zammad" )
106
+ }
107
+
104
108
wh = Webhook .objects .create (
105
109
source = "zammad" ,
106
110
meta = zammad_headers ,
107
111
signature = signature ,
108
112
content = json .loads (request .body ),
109
113
extra = {},
110
114
)
115
+ # Schedule a task for the worker to process the webhook outside of
116
+ # request/response cycle.
111
117
process_webhook .enqueue (str (wh .uuid ))
112
118
return JsonResponse ({"status" : "created" , "guid" : wh .uuid })
113
119
114
-
115
120
return HttpResponseNotAllowed ("Only POST" )
116
121
117
122
0 commit comments