diff options
author | 2024-04-02 19:44:49 +0100 | |
---|---|---|
committer | 2024-04-02 19:44:49 +0100 | |
commit | a70ad816199a3e3a59d7db8e060e24c4c8e9ff88 (patch) | |
tree | bd024ea80c503e22a03821052a70b1c6da8f44a1 /pydis_site/apps/api/views.py | |
parent | Set elidable on RunPython operations in migrations (diff) | |
parent | Merge pull request #1279 from python-discord/add-test-case-drf-3.15-regression (diff) |
Merge branch 'main' into set-elidable-on-run-python-operations-in-migrations
Diffstat (limited to 'pydis_site/apps/api/views.py')
-rw-r--r-- | pydis_site/apps/api/views.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py index 1fa3efc2..a3b0016c 100644 --- a/pydis_site/apps/api/views.py +++ b/pydis_site/apps/api/views.py @@ -303,9 +303,26 @@ class GitHubWebhookFilterView(APIView): (response_status, headers, body) = self.send_webhook( webhook_id, webhook_token, request.data, dict(request.headers), ) - headers.pop('Connection', None) - headers.pop('Content-Length', None) - return Response(data=body, headers=headers, status=response_status) + + body_decoded = body.decode("utf-8") + + if ( + not (status.HTTP_200_OK <= response_status < status.HTTP_300_MULTIPLE_CHOICES) + and response_status != status.HTTP_429_TOO_MANY_REQUESTS + ): + self.logger.warning( + "Failed to send GitHub webhook to Discord. Response code %d, body: %s", + response_status, + body_decoded, + ) + + response_body = { + "original_status": response_status, + "data": body_decoded, + "headers": headers, + } + + return Response(response_body) def send_webhook( self, |