diff --git a/app/config.py b/app/config.py index e83de698b..6e660f8f7 100644 --- a/app/config.py +++ b/app/config.py @@ -567,3 +567,5 @@ def getRateLimitFromConfig( UPCLOUD_USERNAME = os.environ.get("UPCLOUD_USERNAME", None) UPCLOUD_PASSWORD = os.environ.get("UPCLOUD_PASSWORD", None) UPCLOUD_DB_ID = os.environ.get("UPCLOUD_DB_ID", None) + +STORE_TRANSACTIONAL_EMAILS = "STORE_TRANSACTIONAL_EMAILS" in os.environ diff --git a/app/email_utils.py b/app/email_utils.py index c7da8436f..cb42bb8b9 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -1403,7 +1403,7 @@ def generate_verp_email( # Time is in minutes granularity and start counting on 2022-01-01 to reduce bytes to represent time data = [ verp_type.value, - object_id, + object_id or 0, int((time.time() - VERP_TIME_START) / 60), ] json_payload = json.dumps(data).encode("utf-8") diff --git a/app/models.py b/app/models.py index 213f40948..06f585dfa 100644 --- a/app/models.py +++ b/app/models.py @@ -3178,6 +3178,20 @@ class TransactionalEmail(Base, ModelMixin): __table_args__ = (sa.Index("ix_transactional_email_created_at", "created_at"),) + @classmethod + def create(cls, **kw): + # whether to call Session.commit + commit = kw.pop("commit", False) + + r = cls(**kw) + if not config.STORE_TRANSACTIONAL_EMAILS: + return r + + Session.add(r) + if commit: + Session.commit() + return r + class Payout(Base, ModelMixin): """Referral payouts"""