Prevent None callback from causing crashes

This commit is contained in:
moyamo 2016-01-07 21:12:59 +02:00
parent 026f21f43e
commit dbf4a477ec

View file

@ -304,10 +304,11 @@ class YowsupApp(object):
iq = GetSyncIqProtocolEntity(contacts, mode, context) iq = GetSyncIqProtocolEntity(contacts, mode, context)
def onSuccess(response, request): def onSuccess(response, request):
# Remove leading plus # Remove leading plus
existing = [s[1:] for s in response.inNumbers.keys()] if success is not None:
nonexisting = [s[1:] for s in response.outNumbers.keys()] existing = [s[1:] for s in response.inNumbers.keys()]
invalid = [s[1:] for s in response.invalidNumbers] nonexisting = [s[1:] for s in response.outNumbers.keys()]
success(existing, nonexisting, invalid) invalid = [s[1:] for s in response.invalidNumbers]
success(existing, nonexisting, invalid)
self.sendIq(iq, onSuccess = onSuccess, onError = failure) self.sendIq(iq, onSuccess = onSuccess, onError = failure)
@ -324,11 +325,12 @@ class YowsupApp(object):
""" """
iq = GetStatusesIqProtocolEntity([c + '@s.whatsapp.net' for c in contacts]) iq = GetStatusesIqProtocolEntity([c + '@s.whatsapp.net' for c in contacts])
def onSuccess(response, request): def onSuccess(response, request):
self.logger.debug("Received Statuses %s", response) if success is not None:
s = {} self.logger.debug("Received Statuses %s", response)
for k, v in response.statuses.iteritems(): s = {}
s[k.split('@')[0]] = v for k, v in response.statuses.iteritems():
success(s) s[k.split('@')[0]] = v
success(s)
self.sendIq(iq, onSuccess = onSuccess, onError = failure) self.sendIq(iq, onSuccess = onSuccess, onError = failure)