mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
take into account a mailbox can be deleted in the meantime
This commit is contained in:
parent
53f66d0f3c
commit
bb6a5bf0b3
13
cron.py
13
cron.py
@ -288,9 +288,20 @@ def sanity_check():
|
|||||||
Different sanity checks
|
Different sanity checks
|
||||||
- detect if there's mailbox that's using a invalid domain
|
- detect if there's mailbox that's using a invalid domain
|
||||||
"""
|
"""
|
||||||
for mailbox in Mailbox.filter_by(verified=True).all():
|
mailbox_ids = db.session.query(Mailbox.id).filter(Mailbox.verified == True).all()
|
||||||
|
mailbox_ids = [e[0] for e in mailbox_ids]
|
||||||
|
|
||||||
|
# iterate over id instead of mailbox directly
|
||||||
|
# as a mailbox can be deleted during the sleep time
|
||||||
|
for mailbox_id in mailbox_ids:
|
||||||
|
mailbox = Mailbox.get(mailbox_id)
|
||||||
|
# a mailbox has been deleted
|
||||||
|
if not mailbox:
|
||||||
|
continue
|
||||||
|
|
||||||
# hack to not query DNS too often
|
# hack to not query DNS too often
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
if not email_domain_can_be_used_as_mailbox(mailbox.email):
|
if not email_domain_can_be_used_as_mailbox(mailbox.email):
|
||||||
mailbox.nb_failed_checks += 1
|
mailbox.nb_failed_checks += 1
|
||||||
nb_email_log = nb_email_log_for_mailbox(mailbox)
|
nb_email_log = nb_email_log_for_mailbox(mailbox)
|
||||||
|
Loading…
Reference in New Issue
Block a user