@@ -115,7 +115,6 @@ def __get_action_block_for_choices(self, sink: str, choices: Dict[str, CallbackC
115115 ).json (),
116116 }
117117 )
118- logging .info (f"Created action block: { buttons } " )
119118
120119 return [{"type" : "actions" , "elements" : buttons }]
121120
@@ -569,36 +568,48 @@ def send_holmes_analysis(
569568
570569 except Exception :
571570 logging .exception (f"error sending message to slack. { title } " )
571+
572+ def _resolve_slack_thread (
573+ self ,
574+ finding : Finding ,
575+ sink_params : SlackSinkParams ,
576+ thread_ts : Optional [str ] = None ,
577+ ) -> tuple [str , Optional [str ]]:
578+
579+ channel = ChannelTransformer .template (
580+ sink_params .channel_override ,
581+ sink_params .slack_channel ,
582+ self .cluster_name ,
583+ finding .subject .labels ,
584+ finding .subject .annotations ,
585+ )
586+
587+ ctx = getattr (finding , "robusta_context" , {}) or {}
588+ thread_override = ctx .get ("thread_ts" )
589+ channel_override = ctx .get ("channel_id" )
590+
591+ return (
592+ channel_override or channel ,
593+ thread_override or thread_ts ,
594+ )
572595
573596 def send_finding_to_slack (
574597 self ,
575598 finding : Finding ,
576599 sink_params : SlackSinkParams ,
577600 platform_enabled : bool ,
578- thread_ts : str = None ,
601+ thread_ts : Optional [ str ] = None ,
579602 ) -> str :
580603 blocks : List [BaseBlock ] = []
581604 attachment_blocks : List [BaseBlock ] = []
582605
583- slack_channel = ChannelTransformer .template (
584- sink_params .channel_override ,
585- sink_params .slack_channel ,
586- self .cluster_name ,
587- finding .subject .labels ,
588- finding .subject .annotations ,
606+ channel_id , thread_ts = self ._resolve_slack_thread (
607+ finding , sink_params , thread_ts
589608 )
590- robusta_context = getattr (finding , "robusta_context" , None )
591- effective_thread_ts = thread_ts # Default to the one passed in (e.g., from grouping)
592- effective_channel_id = slack_channel
593- if robusta_context :
594- annotation_ts = robusta_context .get ("thread_ts" )
595- channel_id = robusta_context .get ("channel_id" )
596- if annotation_ts : # Make sure it's not None or empty
597- effective_thread_ts = annotation_ts # Prioritize the annotation!
598- effective_channel_id = channel_id
609+
599610 if finding .finding_type == FindingType .AI_ANALYSIS :
600611 # holmes analysis message needs special handling
601- self .send_holmes_analysis (finding , effective_channel_id , platform_enabled , effective_thread_ts )
612+ self .send_holmes_analysis (finding , channel_id , platform_enabled , thread_ts )
602613 return "" # [arik] Looks like the return value here is not used, needs to be removed
603614
604615 status : FindingStatus = (
0 commit comments