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:
@@ -573,13 +573,28 @@ async def translate_document_v1(
|
|||||||
if prompt_id in ("null", "undefined", ""): prompt_id = None
|
if prompt_id in ("null", "undefined", ""): prompt_id = None
|
||||||
if file_url in ("null", "undefined", ""): file_url = None
|
if file_url in ("null", "undefined", ""): file_url = None
|
||||||
|
|
||||||
# Story 3.12 / Bugfix: If user is on the free tier, they might have stale Pro features
|
# 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).
|
# 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":
|
if tier == "free":
|
||||||
glossary_id = None
|
if glossary_id:
|
||||||
custom_prompt = None
|
raise TranslateEndpointError(
|
||||||
prompt_id = None
|
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 file_url:
|
||||||
if tier == "free":
|
if tier == "free":
|
||||||
|
|||||||
Reference in New Issue
Block a user