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:
Timothy Hobbs 2023-09-26 11:36:00 +02:00
parent 1deb42c971
commit 405efcc33b

View File

@ -291,6 +291,7 @@ def imap_oauth_sync(q, logger, server):
except DeleteIgnoredTicketException:
server.store(num, '+FLAGS', '\\Deleted')
server.expunge()
logger.warn("Message %s was ignored and deleted from IMAP server" % num)
except TypeError as te:
@ -300,6 +301,7 @@ def imap_oauth_sync(q, logger, server):
else:
if ticket:
server.store(num, '+FLAGS', '\\Deleted')
server.expunge()
logger.info(
"Successfully processed message %s, deleted from IMAP server" % num)
else: