diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-21 14:48:52 +0000 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:26 +0200 |
commit | ba1d6edfc144c0549e88392a8414a147a9f30931 (patch) | |
tree | 4a66870fb40352bb1dfbef4417761df1e2444605 /service/pixelated/adapter | |
parent | 9b564a2529326668a0752b3b103bffc145d94417 (diff) |
Fixed MarkAsReadUnreadTest#test_mark_single_as_read and underlying implementation.
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/model/mail.py | 15 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 8 |
2 files changed, 14 insertions, 9 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py index dd32d665..5002974f 100644 --- a/service/pixelated/adapter/model/mail.py +++ b/service/pixelated/adapter/model/mail.py @@ -426,18 +426,21 @@ class PixelatedMail(Mail): yield self._persist_mail_tags(tags) defer.returnValue(self.tags) + @defer.inlineCallbacks def mark_as_read(self): if Status.SEEN in self.flags: - return self - self.flags.append(Status.SEEN) - self.save() - return self + defer.returnValue(self) + else: + self.flags.append(Status.SEEN) + yield self.save() + defer.returnValue(self) + @defer.inlineCallbacks def mark_as_unread(self): if Status.SEEN in self.flags: self.flags.remove(Status.SEEN) - self.save() - return self + yield self.save() + defer.returnValue(self) def mark_as_not_recent(self): if Status.RECENT in self.flags: diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index a22ca394..91eeb28f 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -88,13 +88,15 @@ class MailService(object): yield (yield self.mailboxes.drafts).remove(last_draft_ident) defer.returnValue((yield (yield self.mailboxes.sent).add(mail))) + @defer.inlineCallbacks def mark_as_read(self, mail_id): - mail = self.mail(mail_id) - mail.mark_as_read() + mail = yield self.mail(mail_id) + yield mail.mark_as_read() self.search_engine.index_mail(mail) + @defer.inlineCallbacks def mark_as_unread(self, mail_id): - mail = self.mail(mail_id) + mail = yield self.mail(mail_id) mail.mark_as_unread() self.search_engine.index_mail(mail) |