Allow to skip creating transactional emails (#2042)
This commit is contained in:
parent
37f227da42
commit
1dada1a4b5
|
@ -567,3 +567,5 @@ MAX_API_KEYS = int(os.environ.get("MAX_API_KEYS", 30))
|
|||
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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"""
|
||||
|
|
Loading…
Reference in New Issue