This commit is contained in:
+13
-1
@@ -51,6 +51,7 @@ class SubscriptionStatus:
|
||||
grace_expires_at: str = ""
|
||||
manage_url: str = ""
|
||||
notice_id: str = ""
|
||||
real_entitlement_allowed: bool = False
|
||||
|
||||
def __post_init__(self):
|
||||
if self.state not in _ALLOWED_STATES:
|
||||
@@ -58,7 +59,7 @@ class SubscriptionStatus:
|
||||
|
||||
@property
|
||||
def allows_product_workflows(self) -> bool:
|
||||
return self.state in {STATUS_ACTIVE, STATUS_GRACE, STATUS_LEGACY}
|
||||
return self.real_entitlement_allowed
|
||||
|
||||
@property
|
||||
def credentials_accepted(self) -> bool:
|
||||
@@ -184,6 +185,16 @@ def _parse_status_response(data, base_url: str) -> SubscriptionStatus:
|
||||
normalized = _normalize_remote_state(data.get("status"))
|
||||
if not normalized:
|
||||
return SubscriptionStatus(STATUS_UNAVAILABLE)
|
||||
real_entitlement_allowed = data.get("real_entitlement_allowed")
|
||||
if type(real_entitlement_allowed) is not bool:
|
||||
return SubscriptionStatus(STATUS_UNAVAILABLE)
|
||||
if real_entitlement_allowed and normalized not in {
|
||||
STATUS_ACTIVE,
|
||||
STATUS_GRACE,
|
||||
}:
|
||||
return SubscriptionStatus(STATUS_UNAVAILABLE)
|
||||
if normalized in {STATUS_ACTIVE, STATUS_GRACE} and not real_entitlement_allowed:
|
||||
return SubscriptionStatus(STATUS_UNAVAILABLE)
|
||||
account = data.get("account") if isinstance(data.get("account"), dict) else {}
|
||||
plan = data.get("plan") if isinstance(data.get("plan"), dict) else {}
|
||||
account_name = str(account.get("display_name") or "").strip()
|
||||
@@ -211,6 +222,7 @@ def _parse_status_response(data, base_url: str) -> SubscriptionStatus:
|
||||
grace_expires_at=grace_expires_at,
|
||||
manage_url=manage_url,
|
||||
notice_id=notice_id,
|
||||
real_entitlement_allowed=real_entitlement_allowed,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user