diff --git a/imbox/__init__.py b/imbox/__init__.py index 657af78..3c48b30 100644 --- a/imbox/__init__.py +++ b/imbox/__init__.py @@ -60,6 +60,10 @@ def mark_seen(self, uid): logger.info("Mark UID {} with \\Seen FLAG".format(int(uid))) self.connection.uid('STORE', uid, '+FLAGS', '(\\Seen)') + def mark_flag(self, uid): + logger.info("Mark UID {} with \\Flagged FLAG".format(int(uid))) + self.connection.uid('STORE', uid, '+FLAGS', '(\\Flagged)') + def delete(self, uid): logger.info("Mark UID {} with \\Deleted FLAG and expunge.".format(int(uid))) mov, data = self.connection.uid('STORE', uid, '+FLAGS', '(\\Deleted)') diff --git a/imbox/query.py b/imbox/query.py index 417f8b1..f44239c 100644 --- a/imbox/query.py +++ b/imbox/query.py @@ -17,6 +17,8 @@ def build_search_query(**kwargs): # Parse keyword arguments unread = kwargs.get('unread', False) + unflagged = kwargs.get('unflagged', False) + flagged = kwargs.get('flagged', False) sent_from = kwargs.get('sent_from', False) sent_to = kwargs.get('sent_to', False) date__gt = kwargs.get('date__gt', False) @@ -32,6 +34,12 @@ def build_search_query(**kwargs): if unread: query.append("(UNSEEN)") + if unflagged: + query.append("(UNFLAGGED)") + + if flagged: + query.append("(FLAGGED)") + if sent_from: query.append('(FROM "%s")' % sent_from) diff --git a/tests/query_tests.py b/tests/query_tests.py index 40b0b84..195e09a 100644 --- a/tests/query_tests.py +++ b/tests/query_tests.py @@ -15,6 +15,16 @@ def test_unread(self): res = build_search_query(unread=True) self.assertEqual(res, "(UNSEEN)") + def test_unflagged(self): + + res = build_search_query(unflagged=True) + self.assertEqual(res, "(UNFLAGGED)") + + def test_flagged(self): + + res = build_search_query(flagged=True) + self.assertEqual(res, "(FLAGGED)") + def test_sent_from(self): res = build_search_query(sent_from='test@example.com')