summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mail_service.py
diff options
context:
space:
mode:
authorBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-09-22 21:28:59 -0300
committerBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-09-22 21:29:48 -0300
commita68c0cb3dc58a9040a3ad61033742f5a04cc3648 (patch)
tree67c2742c112893dd3d62fa8b35d74ca00032dc0f /service/pixelated/adapter/mail_service.py
parent0db5d5e41cfbd190f54096cad83694813590bc42 (diff)
Added a querier to avoid duplicating the queries (must find a proper place yet) and tweaked pixelated mail to better use the docs
Diffstat (limited to 'service/pixelated/adapter/mail_service.py')
-rw-r--r--service/pixelated/adapter/mail_service.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py
index 60f985da..55407c8d 100644
--- a/service/pixelated/adapter/mail_service.py
+++ b/service/pixelated/adapter/mail_service.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from pixelated.adapter.tag_service import TagService
+from pixelated.adapter.pixelated_mail import PixelatedMail
+from pixelated.adapter.soledad_querier import SoledadQuerier
class MailService:
@@ -24,15 +26,12 @@ class MailService:
def __init__(self, mailboxes, mail_sender, tag_service=TagService.get_instance()):
self.tag_service = tag_service
self.mailboxes = mailboxes
+ self.querier = SoledadQuerier(self.mailboxes.account._soledad)
self.mail_sender = mail_sender
self.tag_service.load_index(self.mails(MailService.ALL_MAILS_QUERY))
def mails(self, query):
- _mails = None
-
- if query['tags']:
- _mails = self.mailboxes.mails_by_tag(query['tags'])
-
+ _mails = self.mailboxes.mails_by_tag(query['tags']) if query['tags'] else self.querier.all_mails()
return sorted(_mails or [], key=lambda mail: mail.headers['date'], reverse=True)
def update_tags(self, mail_id, new_tags):