Реализована проверка версионности и требование soft\force обновлений приложения

This commit is contained in:
mi
2026-09-03 19:12:38 +03:00
parent 465a70d488
commit 44db38f6fe
37 changed files with 3057 additions and 53 deletions
@@ -27,6 +27,96 @@ class OtpSettingsResponse(StrictModel):
cache_ttl_seconds: int = Field(strict=True, gt=0)
class PublicAuthConfig(StrictModel):
phone_enabled: bool
password_enabled: bool
class PublicOperatorConfig(StrictModel):
call_phone: str = Field(min_length=1, max_length=32)
class PublicMessagesConfig(StrictModel):
max_text_length: int = Field(strict=True, ge=1, le=CHAT_MESSAGE_TRANSPORT_MAX_LENGTH)
class PublicConsentConfig(StrictModel):
required: bool
document_url: HttpUrl
version: str = Field(min_length=1, max_length=64)
class PublicPersonalDataConsentConfig(PublicConsentConfig):
privacy_policy_document_url: HttpUrl
class PublicConsentsConfig(StrictModel):
personal_data: PublicPersonalDataConsentConfig
user_agreement: PublicConsentConfig
marketing: PublicConsentConfig
class PublicAttachmentsConfig(StrictModel):
allowed_extensions: list[str]
allowed_mime_types: list[str]
max_size_mb: int = Field(strict=True, gt=0)
class PublicNotificationConfig(StrictModel):
carousel_autoplay_enabled: bool
carousel_autoplay_interval_ms: int = Field(strict=True, gt=0)
class PublicUxConfig(StrictModel):
idle_timeout_minutes: int = Field(strict=True, gt=0)
class MobileStoreUpdatePolicy(StrictModel):
enabled: bool
latest_build: int | None = Field(strict=True, ge=1)
minimum_build: int | None = Field(strict=True, ge=1)
latest_version: str | None = Field(min_length=1, max_length=64)
store_url: HttpUrl | None
release_notes: str | None = Field(max_length=4000)
@model_validator(mode="after")
def validate_policy(self) -> "MobileStoreUpdatePolicy":
release_fields = (
self.latest_build,
self.minimum_build,
self.latest_version,
self.store_url,
)
if self.enabled and any(value is None for value in release_fields):
raise ValueError("enabled update policy requires all release fields")
if not self.enabled and any(value is not None for value in release_fields):
raise ValueError("disabled update policy must not expose release fields")
if (
self.minimum_build is not None
and self.latest_build is not None
and self.minimum_build > self.latest_build
):
raise ValueError("minimum_build must not exceed latest_build")
return self
class MobileUpdatePolicy(StrictModel):
google_play: MobileStoreUpdatePolicy
rustore: MobileStoreUpdatePolicy
app_store: MobileStoreUpdatePolicy
class PublicAppConfigResponse(StrictModel):
auth: PublicAuthConfig
operator: PublicOperatorConfig
messages: PublicMessagesConfig
consents: PublicConsentsConfig
attachments: PublicAttachmentsConfig
notification: PublicNotificationConfig
ux: PublicUxConfig
mobile_update: MobileUpdatePolicy
class Device(StrictModel):
platform: Literal["ios", "android", "web"]
app_version: str = Field(min_length=1, max_length=64)