1.mirror_to_ai_chat: _uuid→uuid(NameError被except吞了, 对话从未同步到webclaw) 2.im_bot_admin加_beijing_now并替换5处datetime.now()(容器UTC存naive时间前端按+08:00展示错位8小时)
This commit is contained in:
1 parent
f975672b0e
commit
ab11283d92
2 files changed
+14
-6
No files matched your search
@@ -14,7 +14,15 @@ import hmac
|
||||
import time
|
||||
import threading
|
||||
import requests
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
# #976 全平台统一使用北京时间(容器 UTC,前端按 +08:00 展示)
|
||||
_TZ_BEIJING = timezone(timedelta(hours=8))
|
||||
|
||||
|
||||
def _beijing_now():
|
||||
"""返回 naive 北京时间(容器 UTC 时区下,需显式转)"""
|
||||
return datetime.now(_TZ_BEIJING).replace(tzinfo=None)
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
@@ -773,13 +781,13 @@ async def wechat_qrcode_status(qrcode: str = Query(...), user=Depends(get_curren
|
||||
(bot_token, ilink_bot_id, baseurl, status, connected_at, created_at, updated_at)
|
||||
VALUES (:bot_token, :ilink_bot_id, :baseurl, 'connected', :connected_at, :created_at, :updated_at)"""),
|
||||
{"bot_token": bot_token, "ilink_bot_id": ilink_bot_id, "baseurl": baseurl,
|
||||
"connected_at": datetime.now(), "created_at": datetime.now(), "updated_at": datetime.now()})
|
||||
"connected_at": _beijing_now(), "created_at": _beijing_now(), "updated_at": _beijing_now()})
|
||||
else:
|
||||
_execute_raw(db, text("""UPDATE im_bot_wechat_account SET
|
||||
bot_token=:bot_token, ilink_bot_id=:ilink_bot_id, baseurl=:baseurl,
|
||||
status='connected', connected_at=:connected_at, updated_at=:updated_at WHERE id=:id"""),
|
||||
{"bot_token": bot_token, "ilink_bot_id": ilink_bot_id, "baseurl": baseurl,
|
||||
"connected_at": datetime.now(), "updated_at": datetime.now(), "id": _row_to_dict(row)["id"]})
|
||||
"connected_at": _beijing_now(), "updated_at": _beijing_now(), "id": _row_to_dict(row)["id"]})
|
||||
row = _wechat_row(db)
|
||||
aid = _row_to_dict(row)["id"] if row else 1
|
||||
_start_wechat_receiver(aid)
|
||||
@@ -821,7 +829,7 @@ async def wechat_disconnect(user=Depends(get_current_user)):
|
||||
row = _wechat_row(db)
|
||||
if row:
|
||||
_execute_raw(db, text("UPDATE im_bot_wechat_account SET bot_token=NULL, status='disconnected', updated_at=:updated_at WHERE id=:id"),
|
||||
{"updated_at": datetime.now(), "id": _row_to_dict(row)["id"]})
|
||||
{"updated_at": _beijing_now(), "id": _row_to_dict(row)["id"]})
|
||||
return {"success": True, "message": "已断开个人微信连接"}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
Reference in new issue
Block a user