落地海运协同群:测服靠会话存档听群话,报价单能带上协同字段。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import logging
|
||||
from typing import Optional
|
||||
|
||||
from agent.redis_coord.client import RedisClient
|
||||
from agent.redis_coord.keys import TOKEN_WECOM
|
||||
from agent.redis_coord.keys import TOKEN_WECOM, TOKEN_WSHOTO
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -40,3 +40,25 @@ def set_wecom_token(
|
||||
key = client.key(TOKEN_WECOM, agent_id)
|
||||
client.raw.set(key, token, ex=ttl_seconds)
|
||||
logger.info("企微 token 已缓存 agent_id=%s ttl=%s", agent_id, ttl_seconds)
|
||||
|
||||
|
||||
def get_wshoto_token(client: RedisClient, *, app_id: str) -> Optional[str]:
|
||||
"""读取微盛 access_token 缓存;未命中返回 None。不把 token 当业务真相。"""
|
||||
key = client.key(TOKEN_WSHOTO, app_id or "default")
|
||||
val = client.raw.get(key)
|
||||
if val is None:
|
||||
return None
|
||||
return val if isinstance(val, str) else val.decode("utf-8")
|
||||
|
||||
|
||||
def set_wshoto_token(
|
||||
client: RedisClient,
|
||||
*,
|
||||
app_id: str,
|
||||
token: str,
|
||||
ttl_seconds: int = 7000,
|
||||
) -> None:
|
||||
"""写入微盛 token;TTL 略短于接口 expires_in,避免用过期票去拉群。"""
|
||||
key = client.key(TOKEN_WSHOTO, app_id or "default")
|
||||
client.raw.set(key, token, ex=max(60, int(ttl_seconds)))
|
||||
logger.info("微盛 token 已缓存 ttl=%s", ttl_seconds)
|
||||
|
||||
Reference in New Issue
Block a user