feat: add admin HWID device limit overrides
This commit is contained in:
@@ -779,9 +779,31 @@ def _get_cached_webapp_settings(request: web.Request) -> Dict[str, Any]:
|
||||
def _resolve_app_version() -> str:
|
||||
# Single source of truth shared with the telemetry worker so the admin
|
||||
# sidebar and the install beacon always report the same version.
|
||||
from bot.utils.app_version import resolve_app_version
|
||||
from bot.utils import app_version as app_version_module
|
||||
|
||||
return resolve_app_version()
|
||||
global _APP_VERSION_CACHE
|
||||
|
||||
app_version_module.APP_ROOT = APP_ROOT
|
||||
app_version_module._run_git_command = _run_git_command
|
||||
app_version_module._APP_VERSION_CACHE = _APP_VERSION_CACHE
|
||||
version = app_version_module.resolve_app_version()
|
||||
_APP_VERSION_CACHE = app_version_module._APP_VERSION_CACHE
|
||||
return version
|
||||
|
||||
|
||||
def _run_git_command(*args: str) -> str:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", *args],
|
||||
cwd=APP_ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=1.5,
|
||||
)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return ""
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
async def _enforce_webapp_rate_limit(
|
||||
|
||||
@@ -342,11 +342,12 @@ def _serialize_subscription(
|
||||
and tariff.premium_topup_packages.has_any()
|
||||
)
|
||||
can_topup_traffic = bool(can_topup_regular_traffic or can_topup_premium_traffic)
|
||||
# max_devices == 0 means unlimited — top-up is pointless in that case.
|
||||
max_devices = _coerce_int_or_none(active.get("max_devices"))
|
||||
# max_devices == 0 or None means unlimited — top-up is pointless in that case.
|
||||
can_topup_devices = bool(
|
||||
tariff.billing_model == "period"
|
||||
and tariff.has_hwid_device_packages()
|
||||
and _coerce_int_or_none(active.get("max_devices")) != 0
|
||||
and max_devices not in (None, 0)
|
||||
)
|
||||
except Exception:
|
||||
can_topup_regular_traffic = False
|
||||
|
||||
Reference in New Issue
Block a user