summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/pixelated_mail.py9
-rw-r--r--service/pixelated/adapter/pixelated_mailbox.py8
-rw-r--r--service/pixelated/adapter/status.py8
3 files changed, 16 insertions, 9 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py
index d39cf81e..97adc964 100644
--- a/service/pixelated/adapter/pixelated_mail.py
+++ b/service/pixelated/adapter/pixelated_mail.py
@@ -27,9 +27,10 @@ class PixelatedMail:
pass
@staticmethod
- def from_leap_mail(leap_mail):
+ def from_leap_mail(leap_mail, leap_mail_collection=None):
mail = PixelatedMail()
mail.leap_mail = leap_mail
+ mail.leap_mail._collection = leap_mail_collection #Work around until they fix the issue of mails not having the collection set on a LeapMailbox
mail.body = leap_mail.bdoc.content['raw']
mail.headers = mail._extract_headers()
mail.date = PixelatedMail._get_date(mail.headers)
@@ -80,7 +81,9 @@ class PixelatedMail:
return added, removed
def mark_as_read(self):
- self.status.add("read")
+ self.leap_mail.setFlags((Status.PixelatedStatus.SEEN,), 1)
+ self.status = self._extract_status()
+ return self
def _persist_mail_tags(self, current_tags):
hdoc = self.leap_mail.hdoc
@@ -136,6 +139,6 @@ def from_dict(mail_dict):
mail.headers['date'] = pixelated.support.date.iso_now()
mail.body = mail_dict.get('body', '')
mail.ident = mail_dict.get('ident', None)
- mail.tags = mail_dict.get('tags', [])
+ mail.tags = set(mail_dict.get('tags', []))
mail.status = set(mail_dict.get('status', []))
return mail
diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py
index 06f30896..4d4d8faa 100644
--- a/service/pixelated/adapter/pixelated_mailbox.py
+++ b/service/pixelated/adapter/pixelated_mailbox.py
@@ -39,7 +39,7 @@ class PixelatedMailbox:
mails = self.leap_mailbox.messages or []
result = []
for mail in mails:
- pixelated_mail = PixelatedMail.from_leap_mail(mail)
+ pixelated_mail = PixelatedMail.from_leap_mail(mail, mails)
self.add_mailbox_tag_if_not_there(pixelated_mail)
result.append(pixelated_mail)
return result
@@ -50,9 +50,9 @@ class PixelatedMailbox:
return [mail for mail in self.mails() if len(mail.tags.intersection(tags)) > 0]
def mail(self, mail_id):
- for message in self.leap_mailbox.messages:
- if gen_pixelated_uid(self.leap_mailbox.mbox, message.getUID()) == mail_id:
- return PixelatedMail.from_leap_mail(message)
+ for message in self.mails():
+ if message.ident == mail_id:
+ return message
@classmethod
def create(cls, account, mailbox_name='INBOX'):
diff --git a/service/pixelated/adapter/status.py b/service/pixelated/adapter/status.py
index 128ccb68..96257414 100644
--- a/service/pixelated/adapter/status.py
+++ b/service/pixelated/adapter/status.py
@@ -17,9 +17,13 @@
class Status:
+ class PixelatedStatus:
+ SEEN = u'\\Seen'
+ ANSWERED = u'\\Answered'
+
LEAP_FLAGS_STATUSES = {
- '\\Seen': 'read',
- '\\Answered': 'replied'
+ PixelatedStatus.SEEN: 'read',
+ PixelatedStatus.ANSWERED: 'replied'
}
@classmethod