Making phone numbers as consistent as possible so user started conversations don...
[theonering] / src / gvoice / conversations.py
index 36aca67..6e08112 100644 (file)
@@ -1,5 +1,9 @@
 #!/usr/bin/python
 
+# @bug False positives on startup.  Luckily the object path for the channel is
+# unique, so can use that to cache some of the data out to file
+
+from __future__ import with_statement
 
 import logging
 
@@ -12,8 +16,8 @@ _moduleLogger = logging.getLogger("gvoice.conversations")
 
 class Conversations(object):
 
-       def __init__(self, backend):
-               self._backend = backend
+       def __init__(self, getter):
+               self._get_raw_conversations = getter
                self._conversations = {}
 
                self.updateSignalHandler = coroutines.CoTee()
@@ -25,10 +29,10 @@ class Conversations(object):
                oldConversationIds = set(self._conversations.iterkeys())
 
                updateConversationIds = set()
-               conversations = list(self._backend.get_conversations())
+               conversations = list(self._get_raw_conversations())
                conversations.sort()
                for conversation in conversations:
-                       key = conversation.contactId, util_misc.strip_number(conversation.number)
+                       key = conversation.contactId, util_misc.normalize_number(conversation.number)
                        try:
                                mergedConversations = self._conversations[key]
                        except KeyError:
@@ -115,7 +119,7 @@ class MergedConversations(object):
                        for newMessage in newConversationMessages
                        if newMessage not in relatedConversation.messages
                ]
-               _moduleLogger.info("Found %d new messages in conversation %s (%d/%d)" % (
+               _moduleLogger.debug("Found %d new messages in conversation %s (%d/%d)" % (
                        len(newConversationMessages) - len(newConversation.messages),
                        newConversation.id,
                        len(newConversation.messages),