diff options
author | 2024-04-02 19:38:06 +0100 | |
---|---|---|
committer | 2024-04-02 19:38:06 +0100 | |
commit | a1201ad1c73ff3b8b76432b5780232dac09d21c5 (patch) | |
tree | 762dc4c7f3d43776218a724ffbe103353ca3cfc7 /pydis_site/apps/api/views.py | |
parent | Add test case for DRF 3.15 regression (diff) | |
parent | Merge pull request #1287 from python-discord/upsert-tags-in-three-queries (diff) |
Merge branch 'main' into add-test-case-drf-3.15-regression
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, |