@@ -73,7 +73,11 @@ def _build_rs_ri_from_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]:
7373
7474 @classmethod
7575 def _build_rs_sr_from_resource (
76- cls , edxl_json : Dict [str , Any ], resource : Dict [str , Any ], case_id : str
76+ cls ,
77+ edxl_json : Dict [str , Any ],
78+ resource : Dict [str , Any ],
79+ case_id : str ,
80+ use_original_distribution_id : bool = False ,
7781 ) -> Dict [str , Any ]:
7882 """Build an RS-SR from a single RC-RI resource, reusing the EDXL envelope."""
7983 logger .info (
@@ -83,8 +87,10 @@ def _build_rs_sr_from_resource(
8387 )
8488 output_json = cls .copy_cisu_input_content (edxl_json )
8589
86- # Set a new distributionID for the RS-SR message
87- cls .set_distribution_id (output_json , f"{ edxl_json ['senderID' ]} _{ uuid .uuid4 ()} " )
90+ if not use_original_distribution_id :
91+ cls .set_distribution_id (
92+ output_json , f"{ edxl_json ['senderID' ]} _{ uuid .uuid4 ()} "
93+ )
8894
8995 output_use_case_json = {
9096 "caseId" : case_id ,
@@ -200,12 +206,17 @@ def from_cisu_to_rs(cls, edxl_json: Dict[str, Any]) -> List[Dict[str, Any]]:
200206 rs_ri = cls ._build_rs_ri_from_cisu (edxl_json )
201207 messages .append (rs_ri )
202208
203- for resource in modified_status_resources :
209+ for idx , resource in enumerate ( modified_status_resources ) :
204210 logger .info (
205211 "Resource %s has a modified status — adding RS-SR to output." ,
206212 resource .get ("resourceId" ),
207213 )
208- rs_sr = cls ._build_rs_sr_from_resource (edxl_json , resource , case_id )
214+ should_use_original_distribution_id = (
215+ not engaged_resources_updated and idx == 0
216+ )
217+ rs_sr = cls ._build_rs_sr_from_resource (
218+ edxl_json , resource , case_id , should_use_original_distribution_id
219+ )
209220 messages .append (rs_sr )
210221
211222 if not messages :
0 commit comments