fix(avatar): keep BOXIM status ready during long polls
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user