Improve hall chat retries, meetup-live lifecycle, home/mine remote-config UX, and add isolated social/API regression tests without deploying. Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
"""公开远程配置 — 供抖音真机拉配置(合法域名 + 有效证书)。
|
||
|
||
门户 nomadro.cn 证书与主机名不匹配,真机会 TLS 失败;
|
||
开发者工具不校验证书所以看起来正常。
|
||
走 dyapi.nomadro.cn / api.nomadro.cn(已在 request 合法域名且证书 OK)。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Any
|
||
|
||
from fastapi import APIRouter
|
||
from fastapi.responses import JSONResponse
|
||
|
||
from ebook_svc.services.tt_platform_config import resolve_config_file
|
||
from ebook_svc.services.public_config_snapshot import PublicConfigSnapshot
|
||
|
||
router = APIRouter(tags=["public-config"])
|
||
_snapshot = PublicConfigSnapshot()
|
||
|
||
|
||
def _read_full_config() -> dict[str, Any]:
|
||
return _snapshot.read(resolve_config_file())
|
||
|
||
|
||
@router.get("/api/config")
|
||
@router.get("/api/ebook/config")
|
||
async def public_remote_config() -> JSONResponse:
|
||
"""对齐门户 GET /api/config:{ ok, source, config }。"""
|
||
config = _read_full_config()
|
||
return JSONResponse(
|
||
content={"ok": True, "source": "file", "config": config},
|
||
headers={
|
||
"Cache-Control": "no-store, no-cache, must-revalidate",
|
||
"Access-Control-Allow-Origin": "*",
|
||
},
|
||
)
|
||
|
||
|
||
@router.get("/api/config/meta")
|
||
@router.get("/api/ebook/config/meta")
|
||
async def public_remote_config_meta() -> JSONResponse:
|
||
config = _read_full_config()
|
||
try:
|
||
version = int(config.get("version") or 0)
|
||
except (TypeError, ValueError, OverflowError):
|
||
version = 0
|
||
return JSONResponse(
|
||
content={
|
||
"ok": True,
|
||
"version": version,
|
||
"updatedAt": str(config.get("updatedAt") or ""),
|
||
},
|
||
headers={
|
||
"Cache-Control": "no-store, no-cache, must-revalidate",
|
||
"Access-Control-Allow-Origin": "*",
|
||
},
|
||
)
|