@@ -326,15 +326,60 @@ public static Dictionary<string, object> AddUserData(this Dictionary<string, obj
326326 /// <returns>The modified data object.</returns>
327327 public static Dictionary < string , object > AddSessionInfoData ( this Dictionary < string , object > dataObject , SessionInfo sessionInfo )
328328 {
329- dataObject [ nameof ( sessionInfo . Id ) ] = sessionInfo . Id ;
329+ if ( ! string . IsNullOrEmpty ( sessionInfo . Id ) )
330+ {
331+ dataObject [ nameof ( sessionInfo . Id ) ] = sessionInfo . Id ;
332+ }
333+
330334 dataObject [ nameof ( sessionInfo . UserId ) ] = sessionInfo . UserId ;
331335 dataObject [ "NotificationUsername" ] = sessionInfo . UserName . Escape ( ) ;
332336 dataObject [ nameof ( sessionInfo . Client ) ] = sessionInfo . Client . Escape ( ) ;
333337 dataObject [ nameof ( sessionInfo . LastActivityDate ) ] = sessionInfo . LastActivityDate ;
334338 dataObject [ nameof ( sessionInfo . LastPlaybackCheckIn ) ] = sessionInfo . LastPlaybackCheckIn ;
335339 dataObject [ nameof ( sessionInfo . DeviceName ) ] = sessionInfo . DeviceName . Escape ( ) ;
336- dataObject [ nameof ( sessionInfo . DeviceId ) ] = sessionInfo . DeviceId ;
337- dataObject [ nameof ( sessionInfo . RemoteEndPoint ) ] = sessionInfo . RemoteEndPoint ;
340+
341+ if ( ! string . IsNullOrEmpty ( sessionInfo . DeviceId ) )
342+ {
343+ dataObject [ nameof ( sessionInfo . DeviceId ) ] = sessionInfo . DeviceId ;
344+ }
345+
346+ if ( ! string . IsNullOrEmpty ( sessionInfo . RemoteEndPoint ) )
347+ {
348+ dataObject [ nameof ( sessionInfo . RemoteEndPoint ) ] = sessionInfo . RemoteEndPoint ;
349+ }
350+
351+ return dataObject ;
352+ }
353+
354+ /// <summary>
355+ /// Add session info data.
356+ /// </summary>
357+ /// <param name="dataObject">The data object.</param>
358+ /// <param name="sessionInfo">The session info to add.</param>
359+ /// <returns>The modified data object.</returns>
360+ public static Dictionary < string , object > AddSessionInfoData ( this Dictionary < string , object > dataObject , SessionInfoDto sessionInfo )
361+ {
362+ if ( ! string . IsNullOrEmpty ( sessionInfo . Id ) )
363+ {
364+ dataObject [ nameof ( sessionInfo . Id ) ] = sessionInfo . Id ;
365+ }
366+
367+ dataObject [ nameof ( sessionInfo . UserId ) ] = sessionInfo . UserId ;
368+ dataObject [ "NotificationUsername" ] = sessionInfo . UserName . Escape ( ) ;
369+ dataObject [ nameof ( sessionInfo . Client ) ] = sessionInfo . Client . Escape ( ) ;
370+ dataObject [ nameof ( sessionInfo . LastActivityDate ) ] = sessionInfo . LastActivityDate ;
371+ dataObject [ nameof ( sessionInfo . LastPlaybackCheckIn ) ] = sessionInfo . LastPlaybackCheckIn ;
372+ dataObject [ nameof ( sessionInfo . DeviceName ) ] = sessionInfo . DeviceName . Escape ( ) ;
373+
374+ if ( ! string . IsNullOrEmpty ( sessionInfo . DeviceId ) )
375+ {
376+ dataObject [ nameof ( sessionInfo . DeviceId ) ] = sessionInfo . DeviceId ;
377+ }
378+
379+ if ( ! string . IsNullOrEmpty ( sessionInfo . RemoteEndPoint ) )
380+ {
381+ dataObject [ nameof ( sessionInfo . RemoteEndPoint ) ] = sessionInfo . RemoteEndPoint ;
382+ }
338383
339384 return dataObject ;
340385 }
0 commit comments