#!/usr/bin/python
+# @bug Its inconsistent as to whether messages from contacts come as from the
+# contact or just a raw number. It seems GV is inconsistent about populating the contact id, so we might have to pull from the addressbook
+# @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
import logging
import util.coroutines as coroutines
+import util.misc as util_misc
_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()
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, conversation.number
+ key = conversation.contactId, util_misc.strip_number(conversation.number)
try:
mergedConversations = self._conversations[key]
except KeyError:
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),