@@ -86,16 +86,18 @@ describe("buildReplyPayloads media filter integration", () => {
8686 resolveReplyTransport : ( {
8787 threadId,
8888 replyToId,
89+ replyToIsExplicit,
8990 replyDelivery,
9091 } : ResolveReplyTransportParams ) => {
92+ const ambientThreadId = threadId != null ? String ( threadId ) : undefined ;
9193 const resolvedThreadId =
9294 replyDelivery ?. chatType === "direct"
9395 ? undefined
94- : replyDelivery
95- ? threadId != null
96- ? String ( threadId )
97- : ( replyToId ?? undefined )
98- : ( replyToId ?? ( threadId != null ? String ( threadId ) : undefined ) ) ;
96+ : replyToIsExplicit
97+ ? ( replyToId ?? ambientThreadId )
98+ : replyDelivery
99+ ? ( ambientThreadId ?? replyToId ?? undefined )
100+ : ( replyToId ?? ambientThreadId ) ;
99101 return {
100102 replyToId : resolvedThreadId ,
101103 threadId : resolvedThreadId ?? null ,
@@ -699,11 +701,11 @@ describe("buildReplyPayloads media filter integration", () => {
699701 expect ( replyPayloads ) . toHaveLength ( 0 ) ;
700702 } ) ;
701703
702- it ( "dedupes an explicit Mattermost reply against the existing thread root" , async ( ) => {
704+ it ( "does not dedupe an explicit Mattermost reply to another thread root" , async ( ) => {
703705 const { replyPayloads } = await buildReplyPayloads ( {
704706 ...baseParams ,
705707 config : { } ,
706- payloads : [ { text : "same reply" , replyToId : "child-post " , replyToTag : true } ] ,
708+ payloads : [ { text : "same reply" , replyToId : "other-root " , replyToTag : true } ] ,
707709 replyToMode : "all" ,
708710 replyToChannel : "mattermost" ,
709711 messageProvider : "mattermost" ,
@@ -722,6 +724,32 @@ describe("buildReplyPayloads media filter integration", () => {
722724 ] ,
723725 } ) ;
724726
727+ expect ( replyPayloads ) . toHaveLength ( 1 ) ;
728+ } ) ;
729+
730+ it ( "dedupes an explicit Mattermost reply to the same thread root" , async ( ) => {
731+ const { replyPayloads } = await buildReplyPayloads ( {
732+ ...baseParams ,
733+ config : { } ,
734+ payloads : [ { text : "same reply" , replyToId : "root-post" , replyToTag : true } ] ,
735+ replyToMode : "all" ,
736+ replyToChannel : "mattermost" ,
737+ messageProvider : "mattermost" ,
738+ originatingChatType : "channel" ,
739+ originatingTo : "channel:C1" ,
740+ originatingThreadId : "ambient-root" ,
741+ messagingToolSentTexts : [ "same reply" ] ,
742+ messagingToolSentTargets : [
743+ {
744+ tool : "mattermost" ,
745+ provider : "mattermost" ,
746+ to : "channel:C1" ,
747+ threadId : "root-post" ,
748+ text : "same reply" ,
749+ } ,
750+ ] ,
751+ } ) ;
752+
725753 expect ( replyPayloads ) . toHaveLength ( 0 ) ;
726754 } ) ;
727755
0 commit comments