imapfilter icon indicating copy to clipboard operation
imapfilter copied to clipboard

[support request] does enter_idle limit the monitoring to one mailbox?

Open dewi-ny-je opened this issue 1 year ago • 3 comments

After years of silent and perfect operation, I was checking imapfilter to see if I could combine the three instances I have into one. I noticed/remembered however that I am using enter_idle, which blocks execution of commands until an update is received.

Is then a separate instance per IMAP server the only solution, or are there better ones?

dewi-ny-je avatar Jan 23 '24 20:01 dewi-ny-je

I know it is not the same, but I combined multiple instances into one with an approach like the one below:

function sync_mail()
  local servers = { server1, server2 }
  for _, server in pairs(servers) do
    msgs = server['INBOX']:select_all()
    if #msgs > 0 then
      ...
    end
  end
end

function forever()
  while true do
    sync_mail()
    sleep(60)
  end
end

recover(forever)

franciscodavid avatar Feb 06 '24 15:02 franciscodavid

It's a periodic check, not IDLE but worth a try.

dewi-ny-je avatar Feb 10 '24 21:02 dewi-ny-je

Well the IMAP IDLE is a blocking network call, so basically the whole program stops waiting for something to be received from the socket. There's a different extension to support multiple mailboxes the IMAP NOTIFY Extension, but it's not supported by imapfilter yet.

But for multiple IDLE on different servers, the only way would be to either have multiple threads or somehow doing non-blocking networking calls with Lua coroutines (eg. Lua Copas or similar).

I think the easiest way is to run multiple processes as you already do, or otherwise don't use IDLE but do periodic polling as suggested.

lefcha avatar Apr 06 '24 09:04 lefcha