I'm working on a Chrome extension that interacts both with the Gmail UI as well as Gmail's IMAP implementation.
The back-end of my app needs to monitor all incoming e-mails for each user and update the DB whenever a message/sender of interest is received.
I can set up a "user initiated" poll, where I scan all new messages whenever they have my app loaded, but there are draw backs since my app is then only up-to-date when the user is in browser. I'd like to be up to date at all times...
Off-hand I've considered a simple server poll of every user, such as:
For x = 0 to All users
Fetch ALL msg where UID > lastMessageID
if msg.sender == something i care about
UPDATE table...
<repeat>
And I've also thought about using IMAP IDLE such as:
For all users, establish imap idle call
for any user whos imap idle returned
if msg.sender == something i care about
UPDATE table...
What I'm trying to figure out though is which is going to scale better as I'll need to monitor 5-10k accounts minimum...
Is there anything I'm missing? Is there a simpler way of doing this for a large number of accounts?
- Note, other than scanning the messages and updating a table -- I do not need to store any of the messages.