Commit ceea6636902649235a6d4a24e732ccee7a9c7011
1 parent
1a63dbe0
fix: getContactNickname 群兜底查 chatroom.displayname
症状:群没有自定义名字时 rcontact.nickname 为空,getContactNickname fallback 返 wxid(如 "57100316212@chatroom"),A11y 拿这个去搜索框 搜不到群,发送失败。 修复:rcontact 没拿到 conRemark/nickname 时,对 @chatroom 后缀的 wxid 额外查 chatroom.displayname,这是微信前端默认拼出来的群名 (如 "丁鹏、🍋火星人、火星人"),可以被 A11y 搜索定位。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Showing
1 changed file
with
14 additions
and
3 deletions
server/services/wechat/android-wechat-tracker-sqlcipher.js
| ... | ... | @@ -151,10 +151,21 @@ class AndroidWechatTrackerSQLCipher extends EventEmitter { |
| 151 | 151 | const out = await this._query(sql, 5000); |
| 152 | 152 | const conRemark = this._extractValue(out, 'conRemark'); |
| 153 | 153 | const nickname = this._extractValue(out, 'nickname'); |
| 154 | - return conRemark || nickname || wxid; | |
| 155 | - } catch (_) { | |
| 156 | - return wxid; | |
| 154 | + if (conRemark || nickname) return conRemark || nickname; | |
| 155 | + } catch (_) {} | |
| 156 | + | |
| 157 | + // 群聊兜底:用户没设群名时,rcontact.nickname 为空,从 chatroom.displayname | |
| 158 | + // 拿微信前端默认拼出来的名字(如 "丁鹏、🍋火星人、火星人") | |
| 159 | + if (wxid.endsWith('@chatroom')) { | |
| 160 | + try { | |
| 161 | + const out2 = await this._query( | |
| 162 | + `SELECT displayname FROM chatroom WHERE chatroomname='${safeWxid}' LIMIT 1;`, 5000); | |
| 163 | + const dn = this._extractValue(out2, 'displayname'); | |
| 164 | + if (dn) return dn; | |
| 165 | + } catch (_) {} | |
| 157 | 166 | } |
| 167 | + | |
| 168 | + return wxid; | |
| 158 | 169 | } |
| 159 | 170 | |
| 160 | 171 | startPolling(intervalMs = 3000) { | ... | ... |