예제 #1
0
def mails():
    query = search_query.compile(request.args.get("q")) if request.args.get("q") else {'tags': {}}

    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: mail.date, reverse=True)

    mails = [mail.as_dict() for mail in mails]

    response = {
        "stats": {
            "total": len(mails),
            "read": 0,
            "starred": 0,
            "replied": 0
        },
        "mails": mails
    }

    return respond_json(response)
예제 #2
0
 def test_tags_with_quotes(self):
     self.assertEquals(search_query.compile(u"in:\"inbox\"")["tags"], ["inbox"])
     self.assertEquals(search_query.compile(u"in:'inbox'")["tags"], ["inbox"])
예제 #3
0
 def test_general_search(self):
     self.assertEquals(search_query.compile(u"searching")["general"], "searching")
예제 #4
0
 def test_tag_negate(self):
     self.assertEquals(search_query.compile(u"-in:trash")["not_tags"], ["trash"])
예제 #5
0
 def test_two_tags_or(self):
     self.assertEquals(search_query.compile(u"in:inbox or in:trash")["tags"], ["inbox", "trash"])
예제 #6
0
 def test_one_tag(self):
     self.assertEquals(search_query.compile(u"in:inbox")["tags"], ["inbox"])
     self.assertEquals(search_query.compile(u"in:trash")["tags"], ["trash"])