Mainframe-Archive / switchboard

A framework for processing email using worker plugins.
switchboard.spatch.co
BSD 3-Clause "New" or "Revised" License
312 stars 37 forks source link

Process existing e-mails #41

Open fg-10 opened 9 years ago

fg-10 commented 9 years ago

After discussing with @jtmoulia a function to process existing e-mails would be very useful. Currently Switchboard only allows to process new e-mails. A function to also process existing e-mails would complete Switchboard for being a full IMAP API.

jtmoulia commented 9 years ago

@flgo this is what I've been working on -- will it get the job done for you?

Processing Existing Emails Using Switchboard

mainframe:process(Account, Mailbox, Queries) searches for and then notifies all subscribers of the messages which satisfy Queries.

Worker/Client API

A worker or client should be able to issue a process command.

Worker command rough draft:

["process", {
    "account": Account,  // Optional, default to all?
    "mailbox": Mailbox,
    "query": {
        "from": From,   // Optional
        "to": To,       // Optional
        ... see below ...
        }
    }
]

A client command would be similar, but without the account arg.

Queries

The Queries can be either a single query or a list of queries.

IMAP to Query:

Order By Support

It would be great to be able to order emails by date, an example use case being a new user signs up, and emails should be processed, most recent first to give a feeling of liveness.

I'm not sure how this would be implemented though -- need to look a bit more through the IMAP spec.

fg-10 commented 9 years ago

Looks great, though I have a couple questions.

Thanks!

jtmoulia commented 9 years ago

How does Switchboard make sure it does not "miss" any e-mails?

Yeah, I hear you -- now that it can process more than just a stream of emails as they arrive, it would be nice to have some sort of guarantee that a portion of emails have been processed.

To do this right, there needs to be a record of what emails have been processed, either through a date received marker (may not be sufficient) or just recording IDs.

What will happen if the server needs a reboot? Gotcha. This goes hand-in-hand with the previous question.

I'm going to plan on working on this as a separate issue. Having this process described above will be useful at a low level, but there needs to be some logic managing processing emails on start.

fg-10 commented 9 years ago

@jtmoulia any news?

jtmoulia commented 9 years ago

I've been tinkering on it, but haven't been able to devote the time needed to complete it.

So, it's progressing, but slowly. I'll report back with updates as I have them. Thanks for the bump -- it's good motivation.

fg-10 commented 9 years ago

@jtmoulia guess switchboard development kind of stopped couple months ago? To bad to see a project with such great potential go inactive :(

jtmoulia commented 9 years ago

@flgo I'll take that bait -- we will support switchboard, just haven't been prioritizing it well. Thanks for the reminder :)

Tho, I'm going to get into issue #40 first.