From: Olivier Matz Date: Sun, 27 Nov 2016 14:40:04 +0000 (+0100) Subject: actions: surround flags with parenthesis X-Git-Url: http://git.droids-corp.org/?p=imapami.git;a=commitdiff_plain;h=aae862167223e90151e2091eee55e1b125b7e22d actions: surround flags with parenthesis It looks that when using uid, some servers expects that the flags are surrounded by parenthesis. Else, we get this error: UID command error: BAD ['Error in IMAP command UID STORE: Flags list contains non-atoms.'] Seen also here: https://github.com/coddingtonbear/django-mailbox/commit/dad65d802c7eab86c88dca3ef466dc4c43daffc0 Signed-off-by: Olivier Matz --- diff --git a/imapami/actions.py b/imapami/actions.py index 8653ea0..ae3c9ef 100644 --- a/imapami/actions.py +++ b/imapami/actions.py @@ -203,8 +203,7 @@ class ImapamiActionChangeFlag(ImapamiAction): cmd = '+FLAGS' else: cmd = '-FLAGS' - flag = '\\' + self.evaluate(self.flag, ami, - mail.msg) + flag = '(\\%s)' % self.evaluate(self.flag, ami, mail.msg) ret, msg = imap.uid("STORE", mail.item, cmd, flag) if ret != "OK": ami.logger.warning( @@ -281,7 +280,7 @@ class ImapamiActionMove(ImapamiAction): ami.logger.warning( "imap copy returned %s: %s" % (ret, str(msg))) return False - ret, msg = imap.uid("STORE", mail.item, '+FLAGS', '\\Deleted') + ret, msg = imap.uid("STORE", mail.item, '+FLAGS', '(\\Deleted)') if ret != "OK": ami.logger.warning( "imap delete returned %s: %s" % (ret, str(msg)))