feat(trigger): add trigger provider management and webhook handling functionality

This commit is contained in:
Harry
2025-08-28 11:46:35 +08:00
parent 7544b5ec9a
commit 87120ad4ac
28 changed files with 2056 additions and 57 deletions

View File

@ -74,10 +74,10 @@ class TenantDailyRateLimiter:
Number of seconds until UTC midnight
"""
utc_now = datetime.utcnow()
# Get next midnight in UTC
next_midnight = datetime.combine(utc_now.date() + timedelta(days=1), time.min)
return int((next_midnight - utc_now).total_seconds())
def check_and_consume(self, tenant_id: str, max_daily_limit: int) -> bool:
@ -174,9 +174,9 @@ class TenantDailyRateLimiter:
"""
tz = pytz.timezone(timezone_str)
utc_now = datetime.utcnow()
# Get next midnight in UTC, then convert to tenant's timezone
next_utc_midnight = datetime.combine(utc_now.date() + timedelta(days=1), time.min)
next_utc_midnight = pytz.UTC.localize(next_utc_midnight)
return next_utc_midnight.astimezone(tz)