Enable nullable for UserItemData
MetadataResult.GetOrAddUserData doesn't ever get used and is probably broken since the migration to .NET Core as it still expects a Guid for userId
This commit is contained in:
parent
eeb8c59ff2
commit
d3f0346f04
|
@ -333,10 +333,10 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// <returns>The user item data.</returns>
|
/// <returns>The user item data.</returns>
|
||||||
private UserItemData ReadRow(SqliteDataReader reader)
|
private UserItemData ReadRow(SqliteDataReader reader)
|
||||||
{
|
{
|
||||||
var userData = new UserItemData();
|
var userData = new UserItemData
|
||||||
|
{
|
||||||
userData.Key = reader[0].ToString();
|
Key = reader.GetString(0)
|
||||||
// userData.UserId = reader[1].ReadGuidFromBlob();
|
};
|
||||||
|
|
||||||
if (reader.TryGetDouble(2, out var rating))
|
if (reader.TryGetDouble(2, out var rating))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -138,13 +137,13 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
return new UserDataChangeInfo
|
return new UserDataChangeInfo
|
||||||
{
|
{
|
||||||
UserId = userId.ToString("N", CultureInfo.InvariantCulture),
|
UserId = userId,
|
||||||
UserDataList = changedItems
|
UserDataList = changedItems
|
||||||
.DistinctBy(x => x.Id)
|
.DistinctBy(x => x.Id)
|
||||||
.Select(i =>
|
.Select(i =>
|
||||||
{
|
{
|
||||||
var dto = _userDataManager.GetUserDataDto(i, user);
|
var dto = _userDataManager.GetUserDataDto(i, user);
|
||||||
dto.ItemId = i.Id.ToString("N", CultureInfo.InvariantCulture);
|
dto.ItemId = i.Id;
|
||||||
return dto;
|
return dto;
|
||||||
})
|
})
|
||||||
.ToArray()
|
.ToArray()
|
||||||
|
|
|
@ -379,7 +379,8 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
private void SetDefaultSubtitleStreamIndex(MediaSourceInfo source, UserItemData userData, User user, bool allowRememberingSelection)
|
private void SetDefaultSubtitleStreamIndex(MediaSourceInfo source, UserItemData userData, User user, bool allowRememberingSelection)
|
||||||
{
|
{
|
||||||
if (userData.SubtitleStreamIndex.HasValue
|
if (userData is not null
|
||||||
|
&& userData.SubtitleStreamIndex.HasValue
|
||||||
&& user.RememberSubtitleSelections
|
&& user.RememberSubtitleSelections
|
||||||
&& user.SubtitleMode != SubtitlePlaybackMode.None
|
&& user.SubtitleMode != SubtitlePlaybackMode.None
|
||||||
&& allowRememberingSelection)
|
&& allowRememberingSelection)
|
||||||
|
@ -411,7 +412,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
private void SetDefaultAudioStreamIndex(MediaSourceInfo source, UserItemData userData, User user, bool allowRememberingSelection)
|
private void SetDefaultAudioStreamIndex(MediaSourceInfo source, UserItemData userData, User user, bool allowRememberingSelection)
|
||||||
{
|
{
|
||||||
if (userData.AudioStreamIndex.HasValue && user.RememberAudioSelections && allowRememberingSelection)
|
if (userData is not null && userData.AudioStreamIndex.HasValue && user.RememberAudioSelections && allowRememberingSelection)
|
||||||
{
|
{
|
||||||
var index = userData.AudioStreamIndex.Value;
|
var index = userData.AudioStreamIndex.Value;
|
||||||
// Make sure the saved index is still valid
|
// Make sure the saved index is still valid
|
||||||
|
@ -434,7 +435,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
if (mediaType == MediaType.Video)
|
if (mediaType == MediaType.Video)
|
||||||
{
|
{
|
||||||
var userData = item is null ? new UserItemData() : _userDataManager.GetUserData(user, item);
|
var userData = item is null ? null : _userDataManager.GetUserData(user, item);
|
||||||
|
|
||||||
var allowRememberingSelection = item is null || item.EnableRememberingTrackSelections;
|
var allowRememberingSelection = item is null || item.EnableRememberingTrackSelections;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -19,17 +17,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private double? _rating;
|
private double? _rating;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user id.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The user id.</value>
|
|
||||||
public Guid UserId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the key.
|
/// Gets or sets the key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The key.</value>
|
/// <value>The key.</value>
|
||||||
public string Key { get; set; }
|
public required string Key { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the users 0-10 rating.
|
/// Gets or sets the users 0-10 rating.
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
#pragma warning disable CA1002, CA2227, CS1591
|
#pragma warning disable CA1002, CA2227, CS1591
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
|
@ -33,8 +31,6 @@ namespace MediaBrowser.Controller.Providers
|
||||||
set => _remoteImages = value;
|
set => _remoteImages = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserItemData> UserDataList { get; set; }
|
|
||||||
|
|
||||||
public List<PersonInfo> People { get; set; }
|
public List<PersonInfo> People { get; set; }
|
||||||
|
|
||||||
public bool HasMetadata { get; set; }
|
public bool HasMetadata { get; set; }
|
||||||
|
@ -68,32 +64,5 @@ namespace MediaBrowser.Controller.Providers
|
||||||
People.Clear();
|
People.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserItemData GetOrAddUserData(string userId)
|
|
||||||
{
|
|
||||||
UserDataList ??= new List<UserItemData>();
|
|
||||||
|
|
||||||
UserItemData userData = null;
|
|
||||||
|
|
||||||
foreach (var i in UserDataList)
|
|
||||||
{
|
|
||||||
if (string.Equals(userId, i.UserId.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
userData = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userData is null)
|
|
||||||
{
|
|
||||||
userData = new UserItemData()
|
|
||||||
{
|
|
||||||
UserId = new Guid(userId)
|
|
||||||
};
|
|
||||||
|
|
||||||
UserDataList.Add(userData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userData;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#nullable disable
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Dto
|
namespace MediaBrowser.Model.Dto
|
||||||
|
@ -66,12 +65,12 @@ namespace MediaBrowser.Model.Dto
|
||||||
/// Gets or sets the key.
|
/// Gets or sets the key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The key.</value>
|
/// <value>The key.</value>
|
||||||
public string Key { get; set; }
|
public required string Key { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the item identifier.
|
/// Gets or sets the item identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The item identifier.</value>
|
/// <value>The item identifier.</value>
|
||||||
public string ItemId { get; set; }
|
public Guid ItemId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#nullable disable
|
using System;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Session
|
namespace MediaBrowser.Model.Session
|
||||||
|
@ -12,12 +12,12 @@ namespace MediaBrowser.Model.Session
|
||||||
/// Gets or sets the user id.
|
/// Gets or sets the user id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user id.</value>
|
/// <value>The user id.</value>
|
||||||
public string UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the user data list.
|
/// Gets or sets the user data list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user data list.</value>
|
/// <value>The user data list.</value>
|
||||||
public UserItemDataDto[] UserDataList { get; set; }
|
public required UserItemDataDto[] UserDataList { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,11 +54,6 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
||||||
result.People = tmpItem.People;
|
result.People = tmpItem.People;
|
||||||
result.Images = tmpItem.Images;
|
result.Images = tmpItem.Images;
|
||||||
result.RemoteImages = tmpItem.RemoteImages;
|
result.RemoteImages = tmpItem.RemoteImages;
|
||||||
|
|
||||||
if (tmpItem.UserDataList is not null)
|
|
||||||
{
|
|
||||||
result.UserDataList = tmpItem.UserDataList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -53,7 +53,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||||
|
|
||||||
var userData = new Mock<IUserDataManager>();
|
var userData = new Mock<IUserDataManager>();
|
||||||
userData.Setup(x => x.GetUserData(_testUser, It.IsAny<BaseItem>()))
|
userData.Setup(x => x.GetUserData(_testUser, It.IsAny<BaseItem>()))
|
||||||
.Returns(new UserItemData());
|
.Returns(new UserItemData()
|
||||||
|
{
|
||||||
|
Key = "Something"
|
||||||
|
});
|
||||||
|
|
||||||
var directoryService = new Mock<IDirectoryService>();
|
var directoryService = new Mock<IDirectoryService>();
|
||||||
_localImageFileMetadata = new FileSystemMetadata()
|
_localImageFileMetadata = new FileSystemMetadata()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user