fix: 修复 thread 消息 channel_type 字符串比较失败导致串频道#179
Closed
Conversation
WuKongIM 在 CommunityTopic 场景下可能推送 channel_type 为字符串 "5" 而非数字 5,导致 === ChannelType.CommunityTopic 比较失败,thread 消息 被误判为 DM,readReceipt/typing 发到私聊、session 路由到 direct。 修复:在消息入口(channel.ts onMessage + inbound.ts handleInboundMessage) 统一 Number() 转换 channel_type,确保后续所有 === 比较正常工作。 Fixes #172 相关 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lml2468
reviewed
Apr 14, 2026
Collaborator
lml2468
left a comment
There was a problem hiding this comment.
Review: LGTM,可以合入
修复逻辑正确:WuKongIM 有时将 channel_type 以字符串 "5" 发出,导致与 ChannelType enum 严格比较失败。两处 Number(msg.channel_type) as ChannelType 正确处理了类型强制转换。
两点值得注意:
-
双重防御设计合理:
channel.ts在入口处规范化,inbound.ts再做一次兜底,注释也明确写了defense-in-depth。可以接受,但如果后续 SDK 修复了类型,记得清理两处。 -
与 #169 冲突风险:两个文件(
channel.ts/inbound.ts)都在 #169 的改动范围内。如果 #169 先合,#179需要 rebase 确认无冲突。
建议合并顺序:先确认 #169 的合并计划再处理 #179,或先合 #179(改动小、独立),再让 #169 在 rebase 时吸收。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WuKongIM 在 CommunityTopic(子区) 场景下可能推送
channel_type为字符串"5"而非数字5,JavaScript 的===不做类型转换,导致:isGroup判定为 false,thread 消息被当成 DM 处理Fix
在消息入口统一
Number()转换channel_type:channel.tsonMessage 回调入口inbound.tshandleInboundMessage 入口(defense-in-depth)Test plan
npm run build通过npm test476 通过🤖 Generated with Claude Code