2162056008
- device 表 + 心跳/注册/liveness 查询/ack 端点 + heartbeat_monitor_worker (扫描超时设备置 kill_alert_pending, 客户端进 App 拉取弹自启动引导) - 本期只做 pull 后置检测, 不接推送(不含 jpush) - 迁移: device_table → device_kill_alert_pending(接 main head ceb286289426, 线性单 head) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
"""设备注册 / 心跳相关 schema(无障碍保护存活检测)。"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class DeviceRegisterRequest(BaseModel):
|
|
device_id: str
|
|
registration_id: str | None = None
|
|
platform: str = "android"
|
|
app_version: str | None = None
|
|
|
|
|
|
class HeartbeatRequest(BaseModel):
|
|
device_id: str
|
|
source: str = "service" # service | app
|
|
accessibility_enabled: bool = True
|
|
registration_id: str | None = None
|
|
|
|
|
|
class DeviceOut(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
device_id: str
|
|
registration_id: str | None
|
|
ever_protected: bool
|
|
liveness_state: str
|
|
last_heartbeat_at: datetime | None
|
|
updated_at: datetime | None
|
|
|
|
|
|
class OkResponse(BaseModel):
|
|
ok: bool = True
|
|
|
|
|
|
class LivenessOut(BaseModel):
|
|
"""本机掉线告警状态(后置检测 pull 版)。设备从未注册过 → 全默认(= 无告警)。"""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
kill_alert_pending: bool = False
|
|
liveness_state: str = "unknown"
|
|
ever_protected: bool = False
|
|
last_heartbeat_at: datetime | None = None
|
|
|
|
|
|
class LivenessAckRequest(BaseModel):
|
|
device_id: str
|