fix: handle forum/topics in Telegram DM thread routing#18021
fix: handle forum/topics in Telegram DM thread routing#18021steipete merged 1 commit intoopenclaw:mainfrom
Conversation
resolveTelegramThreadSpec now checks isForum in the non-group path. DMs with forum/topics enabled return scope 'forum' so each topic gets its own session, while plain DM threads keep scope 'dm'.
Apply fix from openclaw/openclaw PR openclaw#18021. When a DM chat has is_forum=true, return scope 'forum' instead of 'dm' so message_thread_id is preserved for topic-enabled bot DMs. Fixes openclaw#17980
|
|
This is already addressed by PR #18586 ( Timeline:
Between the two PRs, the full fix from #17980 is on
Test coverage was also updated in #18586 across |
|
Reverted in This PR was accidentally merged into |
Fixes #17980
Problem
resolveTelegramThreadSpecdid not checkisForumin the non-group (DM) path. When a Telegram DM chat has forum/topics enabled (e.g. Saved Messages, business accounts), messages arrive withis_forum: trueand amessage_thread_id, but the function returnedscope: "dm"— causing all topics to collapse into a single flat session.Fix
Added an
isForumcheck in the DM path ofresolveTelegramThreadSpec:isForum+messageThreadId→ returns{ id, scope: "forum" }so each topic gets its own session andbuildTelegramThreadParamsincludesmessage_thread_idin API calls.messageThreadId(no forum) → unchanged behavior, returns{ id, scope: "dm" }preserving thread session routing (threadId not saved in deliveryContext for DM topics (Topics in Private Chats) #8891).{ scope: "dm" }.Tests
Added 5 new test cases for
resolveTelegramThreadSpeccovering all DM/group/forum combinations. All existing tests (39 total across 3 related test files) pass.Greptile Summary
Fixed
resolveTelegramThreadSpecto properly handle DM chats with forum/topics enabled (e.g., Saved Messages, business accounts). The function now checksisForumin the DM path and returnsscope: "forum"when bothisForumandmessageThreadIdare present, ensuring each topic gets its own session. This prevents all topics from collapsing into a single flat DM session while preserving existing thread session routing behavior for non-forum DM threads (issue #8891).Key changes:
isForumcheck in DM path before evaluatingmessageThreadIdisForum+messageThreadId→ returns{ id, scope: "forum" }messageThreadId(no forum) → unchanged, returns{ id, scope: "dm" }{ scope: "dm" }Confidence Score: 5/5
isForumcheck to correctly route DM forum topics while preserving all existing behaviors. The 5 new tests comprehensively cover all DM/group/forum/thread combinations, and the change aligns perfectly with howbuildTelegramThreadParamsalready handles theforumvsdmscope distinction. The logic correctly prioritizes the forum check before the non-forum thread check, preventing forum topics from incorrectly falling through to the DM thread path.Last reviewed commit: 405f507
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!