-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launching programs on reception and composition of mail #414
Comments
Have you considered using inotifywait? That's what Pat uses internally to refresh it's state once a new message is received or posted to the outbox. |
Yes, when I said "a perpetually running process or a cron job". It can already be done. There are reasons why I don't consider that a good solution:
Etc, etc. Pat deciding when to invoke the filter instead is the natural solution that doesn't feel like a hack. |
Although I understand it would be easier just to define some hooks in the config, my main concern here is the added complexity to the project when all of this could be implemented using standard unix tools. I mean, where do we draw the line? Some questions that comes to mind:
I believe the answer to some of these questions depends on the concrete use case, so this might need to be configurable as well. Btw, we also provide the |
I am more concerned about managing this extra process than load. Me, I'll be able to do it, no problem. Then I write a program for someone else, through some mischance it gets popular, and people all over are wracking their brains how to properly set it up...
Is a message only written to once by Pat in its lifecycle, though? I'm afraid I haven't gotten that deep yet.
If you ask me, the line should be drawn where Pat would be able to invoke the equivalent of
If the session protocol permits swapping between mail receive and send multiple times per session, and Pat can do that, and pick up newly appearing outbound mail while inbound mail is still transferring, then the hook should trigger immediately -- it's possible that a mail robot will answer a message before the session completes and save everyone time. Otherwise it can wait until the session is complete.
The thread (or goroutine) that saves the message to disk should block until the process exits. Everything else shouldn't.
Keep unfiltered message and save that instead, write an error in the log.
Assuming a filter, save stdout to the file, print stderr in the log.
That would be a handy way to pass configuration variables to some of them, so yes.
No, only when it enters the system and leaves.
Also no.
The most common - but far from only - use case I imagine is what, back in FidoNET era, was called a "mail robot" and is still occasionally seen in the form of email-based services. You send a message to a specially configured address, which a program then acts upon and sends you a reply. A filter is simply a more generic and powerful mechanism for implementing these than reading a mailbox, and beyond simple question-response will also allow general transformations on messages. Like silently converting jpeg images into webp to save transmission time, or transliterating Cyrillic into Latin to make a Russian email readable despite ISO-8859-1. |
Here I am with another feature request.
After spending some time considering the use of Pat as a building block in more complex systems by taking advantage of its mailbox structure, I realized that one feature is missing. While it can be replaced by a perpetually running external process or a cron job, it would be a lot better if Pat could be configured to do it by itself:
Pat should have a configuration option to spawn a child process on a freshly
compose
d mail, (whether it comes in from web ui or otherwise) and another one to spawn one for a freshly received mail. Passing them a filename and not caring further what else it does is sufficient. Piping the entire file through such a process before saving the message on disk is also an option, but more prone to user errors resulting in lost mail.This would permit some hackish solutions for #413, allow a trivial way to solve #37, and otherwise simplify many cool things.
The text was updated successfully, but these errors were encountered: