Make things a lil more robust to voipms errors
This commit is contained in:
@@ -59,8 +59,11 @@ class Gateway(BaseGateway):
|
||||
}) as response:
|
||||
# For whatever cursed reason, this call sometimes returns with
|
||||
# text/html as the content type, so we disable the check
|
||||
json = await response.json(content_type=None)
|
||||
if json['status'] == 'success':
|
||||
return
|
||||
else:
|
||||
raise XMPPError("Received error from voipms")
|
||||
try:
|
||||
json = await response.json(content_type=None)
|
||||
if json['status'] == 'success':
|
||||
return
|
||||
else:
|
||||
raise XMPPError("Received error from voipms")
|
||||
except:
|
||||
raise XMPPError("Failure decoding response from voipms")
|
||||
@@ -92,6 +92,7 @@ class Session(BaseSession[str, Contact]):
|
||||
'all_messages': 1,
|
||||
'content_type': 'json',
|
||||
}) as response:
|
||||
try:
|
||||
json = await response.json()
|
||||
log.debug(f"received messages from voipms {json}")
|
||||
|
||||
@@ -99,6 +100,9 @@ class Session(BaseSession[str, Contact]):
|
||||
return []
|
||||
else:
|
||||
return json['sms']
|
||||
except client_exceptions.ContentTypeError:
|
||||
log.warning("Received non-json response from voipms")
|
||||
return []
|
||||
|
||||
async def on_file(self, chat: Contact, url: str, **_kwargs):
|
||||
f = self.user.registration_form
|
||||
|
||||
Reference in New Issue
Block a user