Use json_or_text helper for parsing webhook responses

This commit is contained in:
I. Ahmad authored and GitHub committed 2022-05-30 08:48:36 -04:00
1 parent f24f34e3f1
commit f82ec46acf
2 files changed
+7 -7

No files matched your search

+5 -2
View File
@@ -178,8 +178,11 @@ class WebhookAdapter:
response.status = response.status_code # type: ignore
data = response.text or None
if data and response.headers['Content-Type'] == 'application/json':
data = json.loads(data)
try:
if data and response.headers['Content-Type'] == 'application/json':
data = json.loads(data)
except KeyError:
pass
remaining = response.headers.get('X-Ratelimit-Remaining')
if remaining == '0' and response.status_code != 429: