From 0846d51423b7b0f6c694e59160362d9a94ee2141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Wed, 2 Aug 2023 17:00:57 +0200 Subject: [PATCH] Updated comments and moved crons to run when load is low --- app/models.py | 18 ++-------------- app/utils.py | 2 +- crontab.yml | 58 ++++++++++++++++++++++++++------------------------- 3 files changed, 33 insertions(+), 45 deletions(-) diff --git a/app/models.py b/app/models.py index 2f493e30a..9242b528a 100644 --- a/app/models.py +++ b/app/models.py @@ -1806,7 +1806,7 @@ def create(cls, **kw): flush = kw.pop("flush", False) # make sure email is lowercase and doesn't have any whitespace - website_email = sanitize_email(kw["website_email"]).replace("\u200f", "") + website_email = sanitize_email(kw["website_email"]) kw["website_email"] = website_email if "reply_email" in kw: kw["reply_email"] = normalize_reply_email(sanitize_email(kw["reply_email"])) @@ -2609,23 +2609,9 @@ def aliases(self) -> [Alias]: @classmethod def create(cls, **kw): - # whether to call Session.commit - commit = kw.pop("commit", False) - flush = kw.pop("flush", False) - if "email" in kw: kw["email"] = sanitize_email(kw["email"]) - - r = cls(**kw) - Session.add(r) - - if commit: - Session.commit() - - if flush: - Session.flush() - - return r + return super().create(**kw) def __repr__(self): return f"" diff --git a/app/utils.py b/app/utils.py index bc7035ca5..e6577b777 100644 --- a/app/utils.py +++ b/app/utils.py @@ -99,7 +99,7 @@ def sanitize_email(email_address: str, not_lower=False) -> str: email_address = email_address.strip().replace(" ", "").replace("\n", " ") if not not_lower: email_address = email_address.lower() - return email_address + return email_address.replace("\u200f", "") class NextUrlSanitizer: diff --git a/crontab.yml b/crontab.yml index ba47303f9..c855fd665 100644 --- a/crontab.yml +++ b/crontab.yml @@ -2,64 +2,66 @@ jobs: - name: SimpleLogin growth stats command: python /code/cron.py -j stats shell: /bin/bash - schedule: "0 0 * * *" + schedule: "15 0 * * *" captureStderr: true - - name: SimpleLogin Notify Trial Ends - command: python /code/cron.py -j notify_trial_end + - name: SimpleLogin Delete Old Monitoring records + command: python /code/cron.py -j delete_old_monitoring shell: /bin/bash - schedule: "0 8 * * *" + schedule: "15 1 * * *" captureStderr: true - - name: SimpleLogin Notify Manual Subscription Ends - command: python /code/cron.py -j notify_manual_subscription_end + - name: SimpleLogin Custom Domain check + command: python /code/cron.py -j check_custom_domain shell: /bin/bash - schedule: "0 9 * * *" + schedule: "15 2 * * *" captureStderr: true - - name: SimpleLogin Notify Premium Ends - command: python /code/cron.py -j notify_premium_end + - name: SimpleLogin HIBP check + command: python /code/cron.py -j check_hibp shell: /bin/bash - schedule: "0 10 * * *" + schedule: "15 3 * * *" captureStderr: true + concurrencyPolicy: Forbid + + - name: SimpleLogin Notify HIBP breaches + command: python /code/cron.py -j notify_hibp + shell: /bin/bash + schedule: "15 4 * * *" + captureStderr: true + concurrencyPolicy: Forbid - name: SimpleLogin Delete Logs command: python /code/cron.py -j delete_logs shell: /bin/bash - schedule: "0 11 * * *" + schedule: "15 5 * * *" captureStderr: true - name: SimpleLogin Poll Apple Subscriptions command: python /code/cron.py -j poll_apple_subscription shell: /bin/bash - schedule: "0 12 * * *" + schedule: "15 6 * * *" captureStderr: true - - name: SimpleLogin Delete Old Monitoring records - command: python /code/cron.py -j delete_old_monitoring + - name: SimpleLogin Notify Trial Ends + command: python /code/cron.py -j notify_trial_end shell: /bin/bash - schedule: "0 14 * * *" + schedule: "15 8 * * *" captureStderr: true - - name: SimpleLogin Custom Domain check - command: python /code/cron.py -j check_custom_domain + - name: SimpleLogin Notify Manual Subscription Ends + command: python /code/cron.py -j notify_manual_subscription_end shell: /bin/bash - schedule: "0 15 * * *" + schedule: "15 9 * * *" captureStderr: true - - name: SimpleLogin HIBP check - command: python /code/cron.py -j check_hibp + - name: SimpleLogin Notify Premium Ends + command: python /code/cron.py -j notify_premium_end shell: /bin/bash - schedule: "0 18 * * *" + schedule: "15 10 * * *" captureStderr: true - concurrencyPolicy: Forbid - - name: SimpleLogin Notify HIBP breaches - command: python /code/cron.py -j notify_hibp - shell: /bin/bash - schedule: "0 19 * * *" - captureStderr: true - concurrencyPolicy: Forbid + - name: SimpleLogin send unsent emails command: python /code/cron.py -j send_undelivered_mails