Skip to content

Commit

Permalink
10.10 (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero authored Oct 26, 2024
1 parent 3d36010 commit 27a2ce9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
51 changes: 48 additions & 3 deletions Jellyfin.Plugin.Webhook/Helpers/DataObjectHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,60 @@ public static Dictionary<string, object> AddUserData(this Dictionary<string, obj
/// <returns>The modified data object.</returns>
public static Dictionary<string, object> AddSessionInfoData(this Dictionary<string, object> dataObject, SessionInfo sessionInfo)
{
dataObject[nameof(sessionInfo.Id)] = sessionInfo.Id;
if (!string.IsNullOrEmpty(sessionInfo.Id))
{
dataObject[nameof(sessionInfo.Id)] = sessionInfo.Id;
}

dataObject[nameof(sessionInfo.UserId)] = sessionInfo.UserId;
dataObject["NotificationUsername"] = sessionInfo.UserName.Escape();
dataObject[nameof(sessionInfo.Client)] = sessionInfo.Client.Escape();
dataObject[nameof(sessionInfo.LastActivityDate)] = sessionInfo.LastActivityDate;
dataObject[nameof(sessionInfo.LastPlaybackCheckIn)] = sessionInfo.LastPlaybackCheckIn;
dataObject[nameof(sessionInfo.DeviceName)] = sessionInfo.DeviceName.Escape();
dataObject[nameof(sessionInfo.DeviceId)] = sessionInfo.DeviceId;
dataObject[nameof(sessionInfo.RemoteEndPoint)] = sessionInfo.RemoteEndPoint;

if (!string.IsNullOrEmpty(sessionInfo.DeviceId))
{
dataObject[nameof(sessionInfo.DeviceId)] = sessionInfo.DeviceId;
}

if (!string.IsNullOrEmpty(sessionInfo.RemoteEndPoint))
{
dataObject[nameof(sessionInfo.RemoteEndPoint)] = sessionInfo.RemoteEndPoint;
}

return dataObject;
}

/// <summary>
/// Add session info data.
/// </summary>
/// <param name="dataObject">The data object.</param>
/// <param name="sessionInfo">The session info to add.</param>
/// <returns>The modified data object.</returns>
public static Dictionary<string, object> AddSessionInfoData(this Dictionary<string, object> dataObject, SessionInfoDto sessionInfo)
{
if (!string.IsNullOrEmpty(sessionInfo.Id))
{
dataObject[nameof(sessionInfo.Id)] = sessionInfo.Id;
}

dataObject[nameof(sessionInfo.UserId)] = sessionInfo.UserId;
dataObject["NotificationUsername"] = sessionInfo.UserName.Escape();
dataObject[nameof(sessionInfo.Client)] = sessionInfo.Client.Escape();
dataObject[nameof(sessionInfo.LastActivityDate)] = sessionInfo.LastActivityDate;
dataObject[nameof(sessionInfo.LastPlaybackCheckIn)] = sessionInfo.LastPlaybackCheckIn;
dataObject[nameof(sessionInfo.DeviceName)] = sessionInfo.DeviceName.Escape();

if (!string.IsNullOrEmpty(sessionInfo.DeviceId))
{
dataObject[nameof(sessionInfo.DeviceId)] = sessionInfo.DeviceId;
}

if (!string.IsNullOrEmpty(sessionInfo.RemoteEndPoint))
{
dataObject[nameof(sessionInfo.RemoteEndPoint)] = sessionInfo.RemoteEndPoint;
}

return dataObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public interface IItemDeletedManager
/// </summary>
/// <param name="item">The deleted item.</param>
public void AddItem(BaseItem item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public Task StopAsync(CancellationToken cancellationToken)
_libraryManager.ItemRemoved -= ItemDeletedHandler;
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
}
};
}
}
}

0 comments on commit 27a2ce9

Please sign in to comment.