mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Minor alterations to @yellowcap's pull request submission:
* Using a query parameter argument (rather than the entire query string) to specify the folder into which e-mail messages should be archived. * Duplicating the IMAP tests; this could probably be a bit more simply done, but we'll at least be verifying both archived and non-archived use cases. * Simplifying some aspects of the documentation to include references to this new feature.
This commit is contained in:
parent
0e0c6cf170
commit
02567acdc2
3 changed files with 70 additions and 18 deletions
|
|
@ -18,7 +18,7 @@ from django_mailbox.transports import Pop3Transport, ImapTransport,\
|
|||
MMDFTransport
|
||||
from django_mailbox.signals import message_received
|
||||
import six
|
||||
from six.moves.urllib.parse import unquote, urlparse
|
||||
from six.moves.urllib.parse import parse_qs, unquote, urlparse
|
||||
|
||||
from .utils import convert_header_to_unicode
|
||||
|
||||
|
|
@ -115,6 +115,10 @@ class Mailbox(models.Model):
|
|||
def _protocol_info(self):
|
||||
return urlparse(self.uri)
|
||||
|
||||
@property
|
||||
def _query_string(self):
|
||||
return parse_qs(self._protocol_info.query)
|
||||
|
||||
@property
|
||||
def _domain(self):
|
||||
return self._protocol_info.hostname
|
||||
|
|
@ -148,7 +152,10 @@ class Mailbox(models.Model):
|
|||
|
||||
@property
|
||||
def archive(self):
|
||||
return self._protocol_info.query
|
||||
archive_folder = self._query_string.get('archive', None)
|
||||
if not archive_folder:
|
||||
return None
|
||||
return archive_folder[0]
|
||||
|
||||
def get_connection(self):
|
||||
if not self.uri:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue