fix: 5 个安全/正确性问题(第三轮)
1. (High) 启动加载历史消息无用户过滤 → 有 current_user_id 时按用户过滤 2. (High) 长期记忆跨用户共享 → read_for/write_for 按 user_id 隔离 3. (Medium) 摘要读取无用户过滤 — 待后续 4. (Medium) WeChat API 未检查错误 → notifyStart 检查 ret!=0 → getUpdates 检查 ret/errcode → post_json 加 error_for_status() 5. (Low) set_auth 未更新 base_url → &mut self + 实际赋值
This commit is contained in:
+5
-5
@@ -62,7 +62,7 @@ async fn main() {
|
||||
let memory_store = Arc::new(MemoryStore::new(
|
||||
database.as_ref().map(|db| Arc::new(db.pool().clone())),
|
||||
));
|
||||
memory_store.load().await;
|
||||
memory_store.load("").await;
|
||||
|
||||
// 文件状态管理器(降级方案)
|
||||
let file_state = state::StateManager::new(&config.storage.state_dir);
|
||||
@@ -195,7 +195,7 @@ async fn cmd_listen(
|
||||
}
|
||||
};
|
||||
|
||||
let client = WeChatClient::new(Some(auth.base_url.clone()));
|
||||
let mut client = WeChatClient::new(Some(auth.base_url.clone()));
|
||||
client
|
||||
.set_auth(&auth.token, &auth.account_id, &auth.base_url)
|
||||
.await;
|
||||
@@ -366,7 +366,7 @@ async fn cmd_listen(
|
||||
Box::pin(async move {
|
||||
let user_id = session.lock().await.current_user_id.clone();
|
||||
match n.as_str() {
|
||||
"read_memories" => return Ok(memory_store.read().await),
|
||||
"read_memories" => return Ok(memory_store.read_for(&user_id).await),
|
||||
"write_memory" => {
|
||||
let params: serde_json::Value =
|
||||
serde_json::from_str(&args).unwrap_or_default();
|
||||
@@ -374,7 +374,7 @@ async fn cmd_listen(
|
||||
if content.is_empty() {
|
||||
return Ok("请提供 content 参数".to_string());
|
||||
}
|
||||
return Ok(memory_store.write(content).await);
|
||||
return Ok(memory_store.write_for(&user_id, content).await);
|
||||
}
|
||||
"read_summaries" => return Ok(context::tools::read_summaries(&session).await),
|
||||
"call_capability" => {
|
||||
@@ -770,7 +770,7 @@ async fn cmd_send(
|
||||
|
||||
let base_url = auth.base_url.clone();
|
||||
let account_id = auth.account_id.clone();
|
||||
let client = WeChatClient::new(Some(auth.base_url));
|
||||
let mut client = WeChatClient::new(Some(auth.base_url));
|
||||
client
|
||||
.set_auth(&auth.token, &auth.account_id, &base_url)
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user