mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
add item to user data save event
This commit is contained in:
@@ -37,37 +37,37 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// Saves the user data.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="userData">The user data.</param>
|
||||
/// <param name="reason">The reason.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// userData
|
||||
/// <exception cref="System.ArgumentNullException">userData
|
||||
/// or
|
||||
/// cancellationToken
|
||||
/// or
|
||||
/// userId
|
||||
/// or
|
||||
/// key
|
||||
/// </exception>
|
||||
public async Task SaveUserData(Guid userId, string key, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
|
||||
/// key</exception>
|
||||
public async Task SaveUserData(Guid userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
|
||||
{
|
||||
if (userData == null)
|
||||
{
|
||||
throw new ArgumentNullException("userData");
|
||||
}
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("userId");
|
||||
}
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
throw new ArgumentNullException("key");
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var key = item.GetUserDataKey();
|
||||
|
||||
try
|
||||
{
|
||||
await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false);
|
||||
@@ -89,7 +89,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
Key = key,
|
||||
UserData = userData,
|
||||
SaveReason = reason,
|
||||
UserId = userId
|
||||
UserId = userId,
|
||||
Item = item
|
||||
|
||||
}, _logger);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
data.Played = true;
|
||||
}
|
||||
|
||||
await _userDataRepository.SaveUserData(user.Id, key, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
|
||||
await _userDataRepository.SaveUserData(user.Id, info.Item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
// Nothing to save here
|
||||
// Fire events to inform plugins
|
||||
@@ -298,7 +298,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
UpdatePlayState(info.Item, data, info.PositionTicks.Value);
|
||||
|
||||
await _userDataRepository.SaveUserData(user.Id, key, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
|
||||
await _userDataRepository.SaveUserData(user.Id, info.Item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PlaybackProgress, this, new PlaybackProgressEventArgs
|
||||
@@ -361,7 +361,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
data.PlaybackPositionTicks = 0;
|
||||
}
|
||||
|
||||
await _userDataRepository.SaveUserData(user.Id, key, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
||||
await _userDataRepository.SaveUserData(user.Id, info.Item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PlaybackStopped, this, new PlaybackProgressEventArgs
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user