diff options
author | Kali Kaneko <kali@leap.se> | 2015-02-24 23:54:56 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-02-25 15:11:07 -0400 |
commit | 2f5ea5dd08fb62203c04d0588dfc2f945c45bf8e (patch) | |
tree | 29fd66258068b190e2660b2cc491e3d8f667b977 /mail/src/leap/mail/incoming/service.py | |
parent | 7d7434911ba406133834098eb28a974b29e64daa (diff) |
undo duplication of add_msg method in mail api
* Set the internal date from within the incoming mail service.
Diffstat (limited to 'mail/src/leap/mail/incoming/service.py')
-rw-r--r-- | mail/src/leap/mail/incoming/service.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mail/src/leap/mail/incoming/service.py b/mail/src/leap/mail/incoming/service.py index 8b5c3713..ea790fe8 100644 --- a/mail/src/leap/mail/incoming/service.py +++ b/mail/src/leap/mail/incoming/service.py @@ -27,6 +27,7 @@ import warnings from email.parser import Parser from email.generator import Generator from email.utils import parseaddr +from email.utils import formatdate from StringIO import StringIO from urlparse import urlparse @@ -117,7 +118,8 @@ class IncomingMail(Service): :param soledad: a soledad instance :type soledad: Soledad - :param inbox: the inbox where the new emails will be stored + :param inbox: the collection for the inbox where the new emails will be + stored :type inbox: MessageCollection :param check_period: the period to fetch new mail, in seconds. @@ -132,7 +134,7 @@ class IncomingMail(Service): self._keymanager = keymanager self._soledad = soledad - self._inbox = inbox + self._inbox_collection = inbox self._userid = userid self._listeners = [] @@ -266,7 +268,7 @@ class IncomingMail(Service): Sends unread event to ui. """ leap_events.signal( - IMAP_UNREAD_MAIL, str(self._inbox.count_unseen())) + IMAP_UNREAD_MAIL, str(self._inbox_collection.count_unseen())) # process incoming mail. @@ -710,7 +712,8 @@ class IncomingMail(Service): :return: A Deferred that will be fired when the messages is stored :rtype: Defferred """ - doc, data = msgtuple + doc, raw_data = msgtuple + insertion_date = formatdate(time.time()) log.msg('adding message %s to local db' % (doc.doc_id,)) def msgSavedCallback(result): @@ -729,7 +732,8 @@ class IncomingMail(Service): d.addCallback(signal_deleted) return d - d = self._inbox.add_raw_message(data, (self.RECENT_FLAG,)) + d = self._inbox_collection.add_msg( + raw_data, (self.RECENT_FLAG,), date=insertion_date) d.addCallbacks(msgSavedCallback, self._errback) return d |