Commit Graph

82 Commits

Author SHA1 Message Date
cc
5e9e5ee597 Merge pull request #1033 from ZhongXiandou/fix/issue-996-account-dir-resolution
fix(account-dir): 修复账号目录解析导致 -3001 错误的两处缺陷 (#996)
2026-05-28 20:43:01 +08:00
aliyun8639545015
48b6b2216f fix(account-dir): 修复账号目录解析导致 -3001 错误的两处缺陷 (#996)
## 问题现象

部分用户在新版 WeFlow 配置 / 启动时持续报错:
  「数据库目录不存在: <dbPath>\<wxid>」(错误码 -3001)

复现条件之一:用户曾在微信里"自定义过微信号",dbPath 下会同时遗留两个
形似的子目录:
  - `<自定义号>`             :旧的、无后缀的目录,里面没有 db_storage
  - `<自定义号>_<4 位后缀>`  :微信 4.x 实际写入数据的目录

## 根因分析

账号目录解析有两处独立缺陷,分别命中不同人群:

1. **dbPathService.findAccountDirs / scanWxidCandidates**
   对名字以 `wxid_` 开头的目录额外要求"段数(按 `_` 切分)≥ 3"才放行,
   会让"未自定义过微信号"的普通用户(真实目录就叫 `wxid_X`)的账号
   完全消失在欢迎页扫描结果里。

2. **config.getAccountDir / accountDirResolver.resolveAccountDir**
   对非 `wxid_` 开头的输入存在错误的"短路返回"分支:
       if (!lowerWxid.startsWith('wxid_')) {
         const direct = join(root, cleanedWxid)
         if (existsSync(direct)) return direct  // ← 没校验里面有没有 db_storage
       }
   叠加 cleanAccountDirName 会把 `<自定义号>_<4 位后缀>` 清洗成 `<自定义号>`,
   于是无论用户保存的 myWxid 是哪个,都会命中旧的、无后缀的空目录,
   最终在 wcdbCore.open 阶段触发 -3001。

## 修复策略

把两个文件中"快速短路返回"的代码路径全部去掉,统一走基于"候选 + 评分"
的扫描流程:

  1) 同时接受**精确匹配**(entry == cleanedWxid) 与
     **后缀匹配**(entry.startsWith(cleanedWxid + '_')) 两种命中;
  2) 用 accountDirLooksValid 过滤掉"看起来根本不像账号目录"的项
     (没有 db_storage 也没有 FileStorage/Image[2]),从而过滤掉残留空目录;
  3) 在剩余候选中按以下优先级排序,取最优:
       - 有 session.db > 没有:区分"真正写入数据" vs "残留空目录";
       - 后缀匹配 > 精确匹配:与微信 4.x 实际写入目录命名一致;
       - 修改时间更新 > 更旧:兜底。

dbPathService 侧不再以"段数"过滤目录,改由新增的 dedupeAccountDirs 处理
"无后缀目录"与"带后缀目录"同时存在时的去重,保留"微信实际在用"那个。

## 兼容性

- 旧版本残留的 myWxid(无论用户存的是无后缀还是带后缀形式)都会被
  正确解析到带 session.db 的目录,用户无需手动修改配置;
- 未自定义微信号的普通用户(目录就叫 `wxid_X`)现在能正常被识别;
- 多账号、自定义微信号目录、绝对路径形式的 dbPath 等其它场景行为不变。

## 改动范围

- electron/services/dbPathService.ts
    findAccountDirs / scanWxidCandidates 不再按段数过滤;
    新增 dedupeAccountDirs / shouldPreferSuffixedDir / hasSessionDb 三个辅助方法。
- electron/services/config.ts
    重写 getAccountDir 扫描分支;新增 accountDirLooksValid /
    accountDirHasSessionDb 两个辅助方法。
- electron/services/accountDirResolver.ts
    与 config.ts 同步重写 resolveAccountDir,去掉错误的短路分支。

Closes #996
2026-05-28 11:04:09 +08:00
Jason
fbd3b78b87 fix: Group Chat Summary 2026-05-23 17:57:24 +08:00
Jason
87b39196c1 feat: Add AI Summaries for Group Chats 2026-05-22 23:50:49 +08:00
Jason
1df4f0e523 feat: Add Chat Analysis 2026-05-17 21:04:14 +08:00
cc
6d419dbe9e Merge pull request #966 from Jasonzhu1207/main
feat: Disable AI Output Truncation & Optimize max_tokens Settings
2026-05-15 06:32:00 +08:00
Jason
482259953c feat: Disable AI Output Truncation & Optimize max_tokens Settings 2026-05-14 23:32:23 +08:00
cc
39e527a21a 修复了全局wxid错误清洗的问题 2026-05-10 15:17:02 +08:00
cc
810a8e9761 #929 2026-05-08 19:33:37 +08:00
cc
a0eee30f7d Merge pull request #909 from Jasonzhu1207/main
feat: add insight inbox
2026-05-05 14:33:03 +08:00
Jason
b4758d690b feat: add AI insight notification toggle 2026-05-05 12:08:32 +08:00
cc
1e3a496021 #887 #875 2026-05-02 19:08:07 +08:00
cc
d53ddb0ba7 Merge branch 'dev' of https://github.com/hicccc77/WeFlow into dev 2026-04-30 00:00:04 +08:00
cc
1fc710ccef 修复底层配置服务混乱的问题 2026-04-29 23:59:56 +08:00
H3CoF6
b1807b21e7 feat: 选择会话的前端界面 2026-04-29 08:07:16 +08:00
H3CoF6
1f0b2613bf feat(image): 新增自动下载大图选项(win32 x64)
Co-authored-by: NineBird <CavanasD@users.noreply.github.com>
2026-04-29 04:05:48 +08:00
Jason
c596d24083 Merge branch 'hicccc77:main' into main 2026-04-28 13:00:15 +08:00
Jason
55a7ce7b66 feat(insight): add moments context gating and prompt integration 2026-04-28 00:14:05 +08:00
cc
7469337aeb fix: support service runtime fallbacks 2026-04-27 23:08:39 +08:00
Jason
42d4982728 feat(settings): add silent startup to tray 2026-04-25 17:42:13 +08:00
Jason
678c08b507 feat(insight): add whitelist/blacklist mode and typed batch selection 2026-04-18 17:45:44 +08:00
cc
e83fcfdc4c Merge pull request #776 from Jasonzhu1207/main
feat(ai): add configurable max_tokens in shared AI settings
2026-04-17 20:23:19 +08:00
Jason
111a1961bf feat(ai): add configurable max_tokens in shared model settings 2026-04-16 23:04:09 +08:00
cc
fd4a214f9f 修复 #773 #714 2026-04-16 22:03:39 +08:00
cc
93bafbd9f7 Merge pull request #760 from Jasonzhu1207/main
feat:AI见解支持结合社交媒体平台消息以进行综合分析
2026-04-14 23:03:49 +08:00
cc
419a53d6ec 图片解密重构 #527 #522 #696;修复 #752 2026-04-14 23:02:06 +08:00
Jason
9f45c3f5eb Merge branch 'hicccc77:main' into main 2026-04-13 23:02:10 +08:00
cc
8f7ece7691 Merge branch 'dev' of https://github.com/hicccc77/WeFlow into dev 2026-04-12 23:37:29 +08:00
cc
86daa8ef06 支持自动化条件导出;优化引导页面提示;支持快速添加账号 2026-04-12 23:37:26 +08:00
Jason
1be03734a4 feat: add experimental Weibo context to AI insights 2026-04-12 20:53:10 +08:00
Jason
a734cedac1 feat: add AI insight debug log export toggle 2026-04-12 15:45:43 +08:00
xuncha
f2f78bb4e2 实现了服务号的推送以及未读 2026-04-12 08:03:12 +08:00
cc
b9af7ffc8c 一些更新 2026-04-11 19:52:40 +08:00
Jason
36bed846b2 chore: merge upstream main into fork main 2026-04-10 20:45:04 +08:00
Jason
afa8bb5fe0 fix: clean up garbled Chinese text 2026-04-10 20:13:46 +08:00
cc
22a2616534 修复密钥问题 2026-04-10 19:23:32 +08:00
Jason
d96000f0d9 Merge branch 'hicccc77:main' into main 2026-04-07 23:05:17 +08:00
cc
43fed79204 Merge pull request #653 from Jasonzhu1207/feature/ai-insight
Feature:增加AI见解功能
2026-04-07 22:21:42 +08:00
Jason
a52619c4d5 Merge pull request #9 from Jasonzhu1207/v0/jasonzhu081207-4751-0177d73e
Enable AI insights and Telegram push notifications
2026-04-06 18:13:03 +08:00
v0
cf40d3ad63 feat: optimize prompt caching and add Telegram push
Add system prompt caching, custom prompt, and Telegram push settings.

Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
2026-04-06 09:56:11 +00:00
Ocean
f7f6252d0b Merge branch 'main' into fix/http-api-security 2026-04-06 14:11:17 +08:00
huanghe
62395b275d fix(security): harden HTTP API service against multiple vulnerabilities
1. Path traversal in /api/v1/media/ — use path.resolve() and verify
   resolved path stays within media base directory
2. DoS via unlimited POST body — add 10MB size limit to parseBody()
3. Default no-auth — reject all requests when httpApiToken is not
   configured instead of silently allowing everything
4. Overly permissive CORS — restrict Access-Control-Allow-Origin from
   wildcard (*) to localhost/127.0.0.1 only
5. Timing attack on token comparison — use crypto.timingSafeEqual()
   instead of === for token verification
6. Unsafe default bind address — revert httpApiHost default from
   0.0.0.0 back to 127.0.0.1 to prevent network exposure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:06:31 +08:00
Jason
b8cd9a8c38 Merge branch 'hicccc77:main' into main 2026-04-06 13:13:15 +08:00
ethan
b8bf29277a 修复与部分引用功能相关联的无法读取解密配置的问题 2026-04-05 17:48:12 -04:00
v0
89f3ec57f5 feat: add configurable AI insight settings and desktop logging
Introduce new configurable fields and log insights to desktop.

Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
2026-04-05 17:20:23 +00:00
v0
5971757a28 feat: add aiInsightWhitelist to settings page
Implement aiInsightWhitelist feature with UI and filtering logic.

Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
2026-04-05 16:42:43 +00:00
v0
93a9df48f4 feat: implement AI insights service and settings tab
Add core insight service and IPC handlers; update config and settings page.

Co-authored-by: Jason <159670257+Jasonzhu1207@users.noreply.github.com>
2026-04-05 15:32:22 +00:00
cc
a0189fdd0a 修复 #597;实现 #556;修复 #623与 #543;修复卡片图片问题 2026-04-04 23:14:54 +08:00
xuncha
758de9949b 新增开机自启动 [Enhancement]: 希望能够支持静默启动和开机自启动
Fixes #516
2026-04-03 21:08:05 +08:00
xuncha
0235ec7edc Merge branch 'dev' into dev 2026-04-03 19:49:29 +08:00