8adad30ff2
- 新增 device 表 + /api/v1/device/{register,heartbeat} + 迁移 device_table
- heartbeat_monitor_worker 周期扫描心跳超时(App 被杀/无障碍停)→ 服务器终端打印告警
(推送本期未接,先用 logger 终端打印代替真实通知;integrations/jpush.py 已备,后续直接替换)
- config / .env.example 增 JPUSH_* / HEARTBEAT_*
- 见 spec(仓库外 e:\codes\spec\accessibility-liveness-push.md)
注:本提交同时快照了并行 session 未提交的 coupon_state 改动 + 相关 migration
(与本功能同迁移链耦合,无法单独拆分,经确认一并提交)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
852 B
Python
37 lines
852 B
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
|