mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
new setting to delete email from server; don't store duplicate emails;
This commit is contained in:
parent
201f568750
commit
5bdd3703f1
3 changed files with 21 additions and 4 deletions
|
|
@ -2,13 +2,18 @@ import logging
|
|||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from django_mailbox.models import Mailbox
|
||||
|
||||
from django_mailbox.models import Mailbox, Message
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def message_not_in_database(message):
|
||||
if Message.objects.filter(message_id__iexact=message['message-id']).exists():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
mailboxes = Mailbox.active_mailboxes.all()
|
||||
|
|
@ -21,7 +26,8 @@ class Command(BaseCommand):
|
|||
'Gathering messages for %s',
|
||||
mailbox.name
|
||||
)
|
||||
messages = mailbox.get_new_mail()
|
||||
|
||||
messages = mailbox.get_new_mail(condition=message_not_in_database)
|
||||
for message in messages:
|
||||
logger.info(
|
||||
'Received %s (from %s)',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue