Commits

Arno Hautala committed 917ceab

modified mirror_sms to archive messages as they are downloaded and stop downloading when an archived message is encountered

  • Participants
  • Parent commits f0b7f3e

Comments (0)

Files changed (1)

examples/mirror_sms.py

 
 conversations = []
 page = 0
-while True:
+archived_sms_reached = False
+while not archived_sms_reached:
     page += 1
     voice.sms(terms={ 'page':('p%d' % page) })
     jsonData = voice.sms.data
     pageconversations = []
     if 'messages' not in jsonData or len(jsonData['messages']) < 1:
         break
+    # need to sort jsonData['messages'] by startTime, probably create messageID list and sort that
     for message in jsonData['messages']:
         getattr(voice,'message')(terms={ 'messageId':jsonData['messages'][message]['id'] })
+        
+        if "inbox" in jsonData['messages'][message]['labels']:
+            voice.archive(jsonData['messages'][message]['id'])
+        else:
+            archived_sms_reached = True
+            break
+            
         pageconversations.append(getattr(voice,'message').data['messages'])
     for i in pageconversations:
         for j in i: