[imapfilter-devel] Conditional Actions in config.lua

Paul imapfilter at airbred.com
Fri Apr 23 11:36:14 EEST 2010


On 18/04/2010 2:07 AM, Lefteris Chatzimparmpas wrote:
>
> You could change the set.lua like this:
>
>     function Set.copy_messages(self, dest)
>         _check_required(dest, 'table')
>
>         return r = true
>         for mbox in pairs(_extract_mailboxes(self)) do
>         if not mbox.copy_messages(mbox, dest, self) then r = false end
>         end
>         return r
>     end
>

Consider this:

     function Set.copy_messages(self, dest)
         _check_required(dest, 'table')
         successful = Set {}
         for mbox in pairs(_extract_mailboxes(self)) do
             successful = successful +  mbox.copy_messages(mbox, dest, self)
         end
         return successful
     end

So mbox.copy_messages builds up a list of successfully copied results, 
and returns them to the caller.

Then my original example would be:

   results = account1.INBOX.select_all()
   successfullytransferred = 
results:copy_messages(account2['personal/incoming'])
   successfullytransferred:move_messages(account1['archived'])

So only those succesfully transferred would be returned, and you could 
then do a new action on them.


More information about the Imapfilter-devel mailing list