Correct the format of the contacts numbers when syncing

This commit is contained in:
moyamo 2016-01-06 17:38:52 +02:00
parent 2895f78ec7
commit 8e1be86319
1 changed files with 8 additions and 1 deletions

View File

@ -291,9 +291,16 @@ class YowsupApp(object):
# TODO: Implement callbacks
mode = GetSyncIqProtocolEntity.MODE_DELTA if delta else GetSyncIqProtocolEntity.MODE_FULL
context = GetSyncIqProtocolEntity.CONTEXT_INTERACTIVE if interactive else GetSyncIqProtocolEntity.CONTEXT_REGISTRATION
# International contacts must be preceded by a plus. Other numbers are
# considered local.
contacts = ['+' + c for c in contacts]
iq = GetSyncIqProtocolEntity(contacts, mode, context)
def onSuccess(response, request):
success(response.inNumbers.keys(), response.outNumbers.keys(), response.invalidNumbers)
# Remove leading plus
existing = [s[1:] for s in response.inNumbers.keys()]
nonexisting = [s[1:] for s in response.outNumbers.keys()]
invalid = [s[1:] for s in response.invalidNumbers]
success(existing, nonexisting, invalid)
self.sendIq(iq, onSuccess = onSuccess, onError = failure)