diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2014-08-18 12:09:12 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-08-18 12:09:12 -0300 |
commit | 2483101553922a93e941eac4c269a35bf2557686 (patch) | |
tree | f912d562625843cbb9d2536e78c3803c503a4129 /service | |
parent | 98be229b62af5066f2ced14e2f8c151069cec1d3 (diff) |
Victor/Folker - review #5 - move code to pixelated_mail and mail_service
Diffstat (limited to 'service')
-rw-r--r-- | service/app/adapter/mail_service.py | 4 | ||||
-rw-r--r-- | service/app/adapter/pixelated_mail.py | 2 | ||||
-rw-r--r-- | service/app/pixelated_user_agent.py | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/service/app/adapter/mail_service.py b/service/app/adapter/mail_service.py index ab9304e0..c8cf5e74 100644 --- a/service/app/adapter/mail_service.py +++ b/service/app/adapter/mail_service.py @@ -34,7 +34,9 @@ class MailService: def mails(self, query): - return self.mailbox.messages or [] + mails = self.mailbox.messages or [] + mails = [PixelatedMail(mail) for mail in mails] + return mails def update_tags(self, mail_id, new_tags): mail = self.mail(mail_id) diff --git a/service/app/adapter/pixelated_mail.py b/service/app/adapter/pixelated_mail.py index 80ed2401..2f1e14e9 100644 --- a/service/app/adapter/pixelated_mail.py +++ b/service/app/adapter/pixelated_mail.py @@ -1,5 +1,6 @@ from app.tags import Tag from app.tags import Tags +import dateutil.parser as dateparser class PixelatedMail: @@ -27,6 +28,7 @@ class PixelatedMail: self.leap_mail = leap_mail self.body = leap_mail.bdoc.content['raw'] self.headers = self.extract_headers() + self.date = dateparser.parse(self.headers['date']) self.ident = leap_mail.getUID() self.status = self.extract_status() self.security_casing = {} diff --git a/service/app/pixelated_user_agent.py b/service/app/pixelated_user_agent.py index e927efd5..105e9618 100644 --- a/service/app/pixelated_user_agent.py +++ b/service/app/pixelated_user_agent.py @@ -57,12 +57,12 @@ def update_draft(): def mails(): query = search_query.compile(request.args.get("q")) if request.args.get("q") else {'tags': {}} - mails = [PixelatedMail(mail) for mail in mail_service.mails(query)] + mails = mail_service.mails(query) if "inbox" in query['tags']: mails = [mail for mail in mails if not mail.has_tag('trash')] - mails = sorted(mails, key=lambda mail: dateparser.parse(mail.headers['date']), reverse=True) + mails = sorted(mails, key=lambda mail: mail.date, reverse=True) mails = [mail.as_dict() for mail in mails] |