]> git.droids-corp.org - imapami.git/commitdiff
actions: fix move
authorOlivier Matz <zer0@platinum>
Wed, 25 Nov 2015 17:52:12 +0000 (18:52 +0100)
committerOlivier Matz <zer0@platinum>
Wed, 25 Nov 2015 17:52:12 +0000 (18:52 +0100)
It is not possible to use ImapamiActionCopy.process() or
ImapamiActionDelete.process() methods on the ImapamiActionMove
object. So just duplicate the code for now.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
imapami/actions.py

index 7525133c530524448edbceefb85c8427b0f7dabf..63f4f52577c99b4117ededbdc9264cccf8b0b07e 100644 (file)
@@ -273,13 +273,19 @@ class ImapamiActionMove(ImapamiAction):
         ImapamiAction.__init__(self, terminal=True)
         self.dest = dest
     def process(self, ami, mail):
-        ret = ImapamiActionCopy.process(
-            self, ami, mail)
-        if ret == False:
+        imap = ami.imap
+        dest = self.evaluate(self.dest, ami, mail.msg)
+        imap.create(dest)
+        ret, msg = imap.copy(mail.item, dest)
+        if ret != "OK":
+            ami.logger.warning(
+                "imap copy returned %s: %s" % (ret, str(msg)))
             return False
-        ret = ImapamiActionDelete.process(
-            self, ami, mail)
-        if ret == False:
+        ret, msg = imap.store(mail.item, '+FLAGS', '\\Deleted')
+        if ret != "OK":
+            ami.logger.warning(
+                "imap store '%s %s' returned %s: %s" % (
+                    cmd, flag, ret, str(msg)))
             return False
         return True
 register(ImapamiActionMove)