@@ -135,22 +135,34 @@ private RecentActivityResponse.ActivityEntry toActivityEntry(
135135 // Resolve targets
136136 final List <RecentActivityResponse .TargetInfo > targets = new ArrayList <>();
137137 for (final var targetId : marker .targetIds ()) {
138+ final String id ;
138139 final String name ;
139140 if (TransactionMarker .TARGET_FLEET .equals (marker .target ())) {
140- // skip the target if it's a fleet we have no permission to
141- if (!isPermitted (CollectorsPermissions .FLEET_READ , targetId )) {
142- continue ;
141+ if (fleetNames .containsKey (targetId )) {
142+ // skip the target if it's a fleet we have no permission to
143+ if (!isPermitted (CollectorsPermissions .FLEET_READ , targetId )) {
144+ continue ;
145+ }
146+ id = targetId ;
147+ name = fleetNames .get (targetId );
148+ } else {
149+ id = null ;
150+ name = "[deleted]" ;
143151 }
144- name = fleetNames .getOrDefault (targetId , targetId );
145152 } else {
146- // skip the target if the user cannot see the target's fleet
147- if (instances .containsKey (targetId )
148- && !isPermitted (CollectorsPermissions .FLEET_READ , instances .get (targetId ).fleetId ())) {
149- continue ;
153+ if (instances .containsKey (targetId )) {
154+ // skip the target if the user cannot see the target's fleet
155+ if (!isPermitted (CollectorsPermissions .FLEET_READ , instances .get (targetId ).fleetId ())) {
156+ continue ;
157+ }
158+ id = targetId ;
159+ name = resolveInstanceHostname (instances , targetId );
160+ } else {
161+ id = null ;
162+ name = "[deleted]" ;
150163 }
151- name = resolveInstanceHostname (instances , targetId );
152164 }
153- targets .add (new RecentActivityResponse .TargetInfo (targetId , name , marker .target ()));
165+ targets .add (new RecentActivityResponse .TargetInfo (id , name , marker .target ()));
154166 }
155167
156168 // Resolve details
@@ -180,10 +192,16 @@ private String resolveInstanceHostname(Map<String, CollectorInstanceDTO> instanc
180192 private Map <String , String > resolveDetails (TransactionMarker marker , Map <String , String > fleetNames ) {
181193 if (marker .type () == MarkerType .FLEET_REASSIGNED && marker .payload () != null ) {
182194 final String newFleetId = marker .payload ().getString ("new_fleet_id" );
183- if (newFleetId != null && isPermitted (CollectorsPermissions .FLEET_READ , newFleetId )) {
184- return Map .of (
185- "new_fleet_id" , newFleetId ,
186- "new_fleet_name" , fleetNames .getOrDefault (newFleetId , newFleetId ));
195+ if (newFleetId != null ) {
196+ if (fleetNames .containsKey (newFleetId )) {
197+ if (isPermitted (CollectorsPermissions .FLEET_READ , newFleetId )) {
198+ return Map .of (
199+ "new_fleet_id" , newFleetId ,
200+ "new_fleet_name" , fleetNames .get (newFleetId ));
201+ }
202+ return Map .of ();
203+ }
204+ return Map .of ("new_fleet_name" , "[deleted]" );
187205 }
188206 }
189207 return Map .of ();
0 commit comments