aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/models.py')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/models.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/models.py b/packages/meshbay-hub/src/meshbay_hub/db/models.py
index e6c7d33..b052e00 100644
--- a/packages/meshbay-hub/src/meshbay_hub/db/models.py
+++ b/packages/meshbay-hub/src/meshbay_hub/db/models.py
@@ -308,6 +308,28 @@ class UserPreference(Base):
value: Mapped[str] = mapped_column(Text, nullable=False)
+class MailQuota(Base):
+ """How much mail has gone where, kept across restarts.
+
+ This was a pair of dicts in `mail.py`, which meant a restart handed out a
+ fresh allowance — and a hub restarts whenever it is deployed. A budget a
+ restart forgets is not a budget, for the same reason the denylist is
+ persisted rather than held in memory (S3).
+
+ One row per thing being counted:
+ `hour` the instance's hourly total
+ `dest:<hash>` one recipient, hashed — this table must not become a
+ list of plaintext addresses (S2)
+ """
+
+ __tablename__ = "mail_quota"
+
+ key: Mapped[str] = mapped_column(String(64), primary_key=True)
+ window_start: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now)
+ count: Mapped[int] = mapped_column(Integer, default=0)
+ last_sent: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
+
+
class HubSetting(Base):
"""
Instance-wide settings an admin changes at runtime from the panel.