summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-08-07 16:58:39 +0200
committerKali Kaneko <kali@leap.se>2013-08-08 14:08:05 +0200
commiteba7034d6c5c843658c9112a9ead5e2a71d884be (patch)
treebf504172f153a6c983fe0476cc3494485c730736 /mail
parent52649f07c7a8821548a6dc406252956eb03a96df (diff)
Fix incoming processing mail.
The deferred was not working properly so messages in the incoming queue were not being processed.
Diffstat (limited to 'mail')
-rw-r--r--mail/src/leap/mail/imap/fetch.py25
-rw-r--r--mail/src/leap/mail/imap/service/imap.py5
2 files changed, 16 insertions, 14 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py
index ee9de3e..44b3124 100644
--- a/mail/src/leap/mail/imap/fetch.py
+++ b/mail/src/leap/mail/imap/fetch.py
@@ -92,12 +92,8 @@ class LeapIncomingMail(object):
"""
Stops the loop that fetches mail.
"""
- if self._loop:
- try:
- self._loop.stop()
- except AssertionError:
- logger.debug("It looks like we tried to stop a "
- "loop that was not running.")
+ if self._loop and self._loop.running is True:
+ self._loop.stop()
def _sync_soledad(self):
log.msg('syncing soledad...')
@@ -106,7 +102,7 @@ class LeapIncomingMail(object):
try:
self._soledad.sync()
doclist = self._soledad.get_from_index("just-mail", "*")
- #log.msg("there are %s mails" % (len(doclist),))
+ log.msg("there are %s mails" % (len(doclist),))
return doclist
except ssl.SSLError as exc:
logger.warning('SSL Error while syncing soledad: %r' % (exc,))
@@ -120,16 +116,20 @@ class LeapIncomingMail(object):
def _process_doclist(self, doclist):
log.msg('processing doclist')
if not doclist:
+ logger.debug("no docs found")
return
for doc in doclist:
+ logger.debug("processing doc: %s" % doc)
keys = doc.content.keys()
if self.ENC_SCHEME_KEY in keys and self.ENC_JSON_KEY in keys:
# XXX should check for _enc_scheme == "pubkey" || "none"
# that is what incoming mail uses.
encdata = doc.content[self.ENC_JSON_KEY]
- d = defer.Deferred(self._decrypt_msg, doc, encdata)
- d.addCallback(self._process_decrypted)
+ d = defer.Deferred(self._decrypt_msg(doc, encdata))
+ d.addCallbacks(self._process_decrypted, log.msg)
+ else:
+ logger.debug('This does not look like a proper msg.')
def _decrypt_msg(self, doc, encdata):
log.msg('decrypting msg')
@@ -138,7 +138,9 @@ class LeapIncomingMail(object):
encdata, key,
# XXX get from public method instead
passphrase=self._soledad._passphrase))
- return doc, decrdata
+
+ # XXX TODO: defer this properly
+ return self._process_decrypted(doc, decrdata)
def _process_decrypted(self, doc, data):
"""
@@ -166,10 +168,9 @@ class LeapIncomingMail(object):
if not rawmsg:
return False
logger.debug('got incoming message: %s' % (rawmsg,))
- #log.msg("we got raw message")
# add to inbox and delete from soledad
- self.inbox.addMessage(rawmsg, (self.RECENT_FLAG,))
+ self._inbox.addMessage(rawmsg, (self.RECENT_FLAG,))
doc_id = doc.doc_id
self._soledad.delete_doc(doc)
log.msg("deleted doc %s from incoming" % doc_id)
diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py
index 9e331b6..2ae3012 100644
--- a/mail/src/leap/mail/imap/service/imap.py
+++ b/mail/src/leap/mail/imap/service/imap.py
@@ -34,8 +34,9 @@ from leap.soledad import Soledad
IMAP_PORT = 9930
# The default port in which imap service will run
-# INCOMING_CHECK_PERIOD = 5
-INCOMING_CHECK_PERIOD = 60
+# TODO: Make this configurable
+INCOMING_CHECK_PERIOD = 5
+#INCOMING_CHECK_PERIOD = 60
# The period between succesive checks of the incoming mail
# queue (in seconds)