diff options
author | Filipp Lepalaan <filipp@mac.com> | 2021-06-15 09:33:30 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2021-06-15 09:33:30 +0300 |
commit | 3421b809f432ee49586df91b627ef70aa3e07cbf (patch) | |
tree | 5fe385c7abed6d35ee3a09e644031e2423ac819a /servo | |
parent | 612e893bc87c4a81e2a98de75c2242c319edcaf9 (diff) | |
download | Servo-3421b809f432ee49586df91b627ef70aa3e07cbf.tar.gz Servo-3421b809f432ee49586df91b627ef70aa3e07cbf.tar.bz2 Servo-3421b809f432ee49586df91b627ef70aa3e07cbf.zip |
Use tasks.check_mail in commands.checkmail
Diffstat (limited to 'servo')
-rw-r--r-- | servo/management/commands/checkmail.py | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/servo/management/commands/checkmail.py b/servo/management/commands/checkmail.py index 07d5727..6a20f2f 100644 --- a/servo/management/commands/checkmail.py +++ b/servo/management/commands/checkmail.py @@ -1,34 +1,12 @@ # -*- coding: utf-8 -*- -import logging -from email.parser import Parser - from django.core.management.base import BaseCommand -from servo.models import Configuration, Note, User +from servo.tasks import check_mail class Command(BaseCommand): help = "Checks IMAP box for new mail" def handle(self, *args, **options): - uid = Configuration.conf('imap_act') - - if uid == '': - raise ValueError('Incoming message user not configured') - - user = User.objects.get(pk=uid) - server = Configuration.get_imap_server() - typ, data = server.search(None, "UnSeen") - - for num in data[0].split(): - #logging.debug("** Processing message %s" % num) - typ, data = server.fetch(num, "(RFC822)") - # parsestr() seems to return an email.message? - msg = Parser().parsestr(data[0][1]) - Note.from_email(msg, user) - #server.copy(num, 'servo') - server.store(num, '+FLAGS', '\\Seen') - - server.close() - server.logout() + check_mail() |