@@ -86,50 +86,6 @@ type TelegramStatusReactionController = {
8686 restoreInitial : ( ) => void | Promise < void > ;
8787} ;
8888
89- function normalizeTelegramNativeThreadMessageId ( value : unknown ) : string | undefined {
90- if ( typeof value === "number" && Number . isFinite ( value ) ) {
91- return String ( Math . trunc ( value ) ) ;
92- }
93- if ( typeof value !== "string" ) {
94- return undefined ;
95- }
96- const trimmed = value . trim ( ) ;
97- return trimmed ? trimmed : undefined ;
98- }
99-
100- function resolveTelegramNativeReplyRootThreadId ( params : {
101- isGroup : boolean ;
102- isForum : boolean ;
103- resolvedThreadId ?: number ;
104- msg : BuildTelegramMessageContextParams [ "primaryCtx" ] [ "message" ] ;
105- replyChain : NonNullable < BuildTelegramMessageContextParams [ "replyChain" ] > ;
106- } ) : string | undefined {
107- if ( ! params . isGroup || ! params . isForum ) {
108- return undefined ;
109- }
110-
111- const chainRootId = params . replyChain
112- . toReversed ( )
113- . map ( ( entry ) => normalizeTelegramNativeThreadMessageId ( entry . messageId ) )
114- . find ( Boolean ) ;
115- const directReplyId =
116- params . msg . reply_to_message ?. forum_topic_created ||
117- params . msg . reply_to_message ?. forum_topic_edited ||
118- params . msg . reply_to_message ?. forum_topic_closed ||
119- params . msg . reply_to_message ?. forum_topic_reopened
120- ? undefined
121- : normalizeTelegramNativeThreadMessageId ( params . msg . reply_to_message ?. message_id ) ;
122- const rootMessageId =
123- chainRootId ?? directReplyId ?? normalizeTelegramNativeThreadMessageId ( params . msg . message_id ) ;
124- if ( ! rootMessageId ) {
125- return undefined ;
126- }
127-
128- const topicPrefix =
129- params . resolvedThreadId != null ? `topic:${ Math . trunc ( params . resolvedThreadId ) } :` : "" ;
130- return `${ topicPrefix } message:${ rootMessageId } ` ;
131- }
132-
13389export type TelegramMessageContext = {
13490 ctxPayload : TelegramMessageContextPayload [ "ctxPayload" ] ;
13591 turn : TelegramMessageContextPayload [ "turn" ] ;
@@ -307,9 +263,6 @@ export const buildTelegramMessageContext = async ({
307263 candidate . matchedBy === "default" ;
308264 const isNamedAccountFallback = requiresExplicitAccountBinding ( route ) ;
309265 const hasExplicitTopicRoute = isGroup && Boolean ( topicConfig ?. agentId ?. trim ( ) ) ;
310- // Named-account groups still require an explicit binding; DMs get a
311- // per-account fallback session key below to preserve isolation. An explicit
312- // account-scoped topic agent is a configured group route, not a fallback.
313266 if ( isNamedAccountFallback && isGroup && ! hasExplicitTopicRoute ) {
314267 logInboundDrop ( {
315268 log : logVerbose ,
@@ -459,26 +412,10 @@ export const buildTelegramMessageContext = async ({
459412 dmThreadId,
460413 botHasTopicsEnabled : resolveTelegramBotHasTopicsEnabled ( primaryCtx . me ) ,
461414 } ) ;
462- const nativeReplyRootThreadId =
463- bindingMode . kind !== "none"
464- ? undefined
465- : resolveTelegramNativeReplyRootThreadId ( {
466- isGroup,
467- isForum,
468- resolvedThreadId,
469- msg,
470- replyChain,
471- } ) ;
472415 const threadKeys =
473416 useDmThreadSession && dmThreadId != null
474417 ? resolveThreadSessionKeys ( { baseSessionKey, threadId : `${ chatId } :${ dmThreadId } ` } )
475- : nativeReplyRootThreadId
476- ? resolveThreadSessionKeys ( {
477- baseSessionKey,
478- threadId : nativeReplyRootThreadId ,
479- parentSessionKey : baseSessionKey ,
480- } )
481- : null ;
418+ : null ;
482419 const sessionKey = threadKeys ?. sessionKey ?? baseSessionKey ;
483420 route = {
484421 ...route ,
0 commit comments