mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-01-23 14:28:55 +01:00
Delete emails immediately to prevent duplicate ticket problems
Right now if there is an exception in this loop due to a single messed up email (perhapse an invalid email address), the loop will fail without deleting the already processed emails. In a few hours you can end up with hundreds of duplicate tickets. This way, the already processed emails will be deleted and not processed again.
This commit is contained in:
parent
1deb42c971
commit
405efcc33b
@ -291,6 +291,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
|
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
server.store(num, '+FLAGS', '\\Deleted')
|
server.store(num, '+FLAGS', '\\Deleted')
|
||||||
|
server.expunge()
|
||||||
logger.warn("Message %s was ignored and deleted from IMAP server" % num)
|
logger.warn("Message %s was ignored and deleted from IMAP server" % num)
|
||||||
|
|
||||||
except TypeError as te:
|
except TypeError as te:
|
||||||
@ -300,6 +301,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
else:
|
else:
|
||||||
if ticket:
|
if ticket:
|
||||||
server.store(num, '+FLAGS', '\\Deleted')
|
server.store(num, '+FLAGS', '\\Deleted')
|
||||||
|
server.expunge()
|
||||||
logger.info(
|
logger.info(
|
||||||
"Successfully processed message %s, deleted from IMAP server" % num)
|
"Successfully processed message %s, deleted from IMAP server" % num)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user