-
Notifications
You must be signed in to change notification settings - Fork 166
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
Best way to implement IMAP IDLE? #186
Comments
@TravisDart , are you sure imaplib2 support I think it's best to do it based on imaplib2. This requires the introduction of a pluggable transport backend mechanism. Now lists of backend are hard-coded ( django-mailbox/django_mailbox/models.py Lines 182 to 226 in e068738
EmailTransport and can use watch .
I do not have free time to implement it, but I can assist. |
The watch() method would an addition to Django Mailbox and would fetch messages from imaplib2 and store the messages in Django. So, rather than change the existing ImapTransport, we should create another transport (say, StreamingImapTransport) and integrate it into Django Mailbox through a new pluggable transport system? Not quite sure what you're envisioning with the pluggable transport system. |
I think that the selected code snippet requires rewriting so that it is possible to dynamically add pluggable forms of transport (protocol) and then add django-mailbox/django_mailbox/models.py Line 226 in e068738
transport_registry.get_for_type(self.type).from_uri(self.uri) I also think that there should be a new transport instead of modifying the current one. |
It sound like it'd be best to make each 3rd-party transport a Django app. The transport could add itself to the transport registry in the app.py. Honestly, it seems we're drifting off topic. I was wanting to implement IMAP IDLE, and I'm now implementing a pluggable transport system. I guess this is okay if it doesn't take us too far out of our way, but I was kind of thinking it'd just be a matter of hard-coding another transport like we already have. |
@TravisDart , I added some POC of pluggable transport registry: #188 I'd rather not add additional dependency to this library. Therefore, transports that use atypical libraries must be pluggable so that you can simply add custom transports with non-standard dependencies. |
I have an IMAP inbox and I want to listen for incoming mail. IMAP-wise, this can be done with the IDLE command. What would be the best way to implement this in Django Mailbox?
Currently, Django Mailbox uses imaplib, which doesn't natively support IDLE. One solution monkey patches imaplib. While monkey-patching is generally undesirable, the solution looks minimally invasive. (Note that I haven't delved into the implementation details of IDLE or tested this code.)
There's also an imaplib2 module (src) which supports IDLE, and replaces imaplib (with caveats). Yet changing modules seem more invasive that the monkey patch above.
As far as Django Mailbox goes, maybe a
watch()
method could be added to the ImapTransport class and run with a management command?The text was updated successfully, but these errors were encountered: