fix(translate): enforce Pro feature gating for glossary, custom_prompt and prompt_id
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m40s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m40s
This commit is contained in:
@@ -575,11 +575,26 @@ async def translate_document_v1(
|
||||
|
||||
# Story 3.12 / Bugfix: If user is on the free tier, they might have stale Pro features
|
||||
# in their frontend localStorage (e.g., they downgraded, or switched accounts).
|
||||
# Instead of hard-blocking the translation, we simply strip the Pro features.
|
||||
# These features require a paid plan.
|
||||
if tier == "free":
|
||||
glossary_id = None
|
||||
custom_prompt = None
|
||||
prompt_id = None
|
||||
if glossary_id:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.PRO_FEATURE_REQUIRED,
|
||||
message="Glossaries are reserved for Pro users.",
|
||||
details={"feature": "glossary_id", "tier": tier},
|
||||
)
|
||||
if custom_prompt:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.PRO_FEATURE_REQUIRED,
|
||||
message="Custom prompts are reserved for Pro users.",
|
||||
details={"feature": "custom_prompt", "tier": tier},
|
||||
)
|
||||
if prompt_id:
|
||||
raise TranslateEndpointError(
|
||||
code=TranslateEndpointError.PRO_FEATURE_REQUIRED,
|
||||
message="Saved prompts are reserved for Pro users.",
|
||||
details={"feature": "prompt_id", "tier": tier},
|
||||
)
|
||||
|
||||
if file_url:
|
||||
if tier == "free":
|
||||
|
||||
Reference in New Issue
Block a user