fix(avatar): keep BOXIM status ready during long polls

This commit is contained in:
stefanfeng
2026-08-20 15:58:07 +08:00
parent 89f52963b7
commit 64b7680ec4
2 changed files with 27 additions and 2 deletions
@@ -12,6 +12,7 @@ from routers.authorizations import _require_authorization
from routers.avatars import _require_owned_avatar
router = APIRouter(tags=["分身接管"])
BOXIM_STATUS_FRESH_SECONDS = 60
@router.get("/avatar/{avatar_id}/takeover/status")
@@ -44,7 +45,9 @@ def get_takeover_status(
cursor
and cursor.initialized
and cursor.last_polled_at
and cursor.last_polled_at >= datetime.utcnow() - timedelta(seconds=15)
# BOXIM offline-message reads can long-poll for about 20 seconds.
and cursor.last_polled_at
>= datetime.utcnow() - timedelta(seconds=BOXIM_STATUS_FRESH_SECONDS)
):
status, message = "ready", "BOXIM 已连接,收到私聊消息 3 秒后自动回复"
else: