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