Use json_or_text helper for parsing webhook responses

This commit is contained in:
I. Ahmad
2022-05-30 17:48:36 +05:00
committed by GitHub
parent f24f34e3f1
commit f82ec46acf
2 changed files with 7 additions and 7 deletions

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: