summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/pixelated_mailbox.py
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-22 18:53:52 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-22 18:53:52 -0300
commit0db5d5e41cfbd190f54096cad83694813590bc42 (patch)
tree35ea0253765dab11df9028f13e84954258c81d04 /service/pixelated/adapter/pixelated_mailbox.py
parentffc08b7c5b449246cc00ff9d7425c6fecf3a0cfb (diff)
Moving soledad code to pixelated mailbox and making it work with the app - disabling some stuff to do so
Diffstat (limited to 'service/pixelated/adapter/pixelated_mailbox.py')
-rw-r--r--service/pixelated/adapter/pixelated_mailbox.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py
index 4d558ea3..167092d8 100644
--- a/service/pixelated/adapter/pixelated_mailbox.py
+++ b/service/pixelated/adapter/pixelated_mailbox.py
@@ -37,19 +37,25 @@ class PixelatedMailbox:
return self.leap_mailbox.mbox
def add_mailbox_tag_if_not_there(self, pixelated_mail):
- if not pixelated_mail.has_tag(self.mailbox_tag) and pixelated_mail.is_recent:
+ if not pixelated_mail.has_tag(self.mailbox_tag):
pixelated_mail.update_tags({self.mailbox_tag}.union(pixelated_mail.tags))
self.tag_service.notify_tags_updated({self.mailbox_tag}, [], pixelated_mail.ident)
pixelated_mail.mark_as_not_recent()
def mails(self):
- mails = self.leap_mailbox.messages or []
+ soledad = self.leap_mailbox._soledad
+
+ fdocs_chash = [(fdoc, fdoc.content['chash']) for fdoc in soledad.get_from_index('by-type-and-mbox', 'flags', self.leap_mailbox.mbox)]
+ fdocs_hdocs = [(f[0], soledad.get_from_index('by-type-and-contenthash', 'head', f[1])[0]) for f in fdocs_chash]
+ fdocs_hdocs_phash = [(f[0], f[1], f[1].content.get('body')) for f in fdocs_hdocs]
+ fdocs_hdocs_bdocs = [(f[0], f[1], soledad.get_from_index('by-type-and-payloadhash', 'cnt', f[2])[0]) for f in fdocs_hdocs_phash]
+
+ mails = [PixelatedMail.from_soledad(*raw_mail) for raw_mail in fdocs_hdocs_bdocs]
+
result = []
for mail in mails:
- mail._collection = mails
- pixelated_mail = PixelatedMail.from_leap_mail(mail)
- self.add_mailbox_tag_if_not_there(pixelated_mail)
- result.append(pixelated_mail)
+ self.add_mailbox_tag_if_not_there(mail)
+ result.append(mail)
return result
def mails_by_tags(self, tags):