Files
altium-render-engine/backend/app/expiry.py
T
2026-11-09 14:55:36 +03:30

16 خطوط
593 B
Python

"""Link expiry policy. -1 is a persistent no-expiry sentinel, not a timestamp."""
from fastapi import HTTPException
from .config import settings
NEVER_EXPIRES = -1
def expiration(expires_in, now):
if expires_in == NEVER_EXPIRES:
return NEVER_EXPIRES
ttl = settings().link_ttl if expires_in is None else expires_in
if ttl <= 0 or ttl > settings().link_ttl:
raise HTTPException(422, {'code': 'invalid_expiry',
'message': 'expires_in must be -1 (no expiry) or positive seconds within the configured lifetime'})
return now + ttl