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>
|
||||
private UserItemData ReadRow(SqliteDataReader reader)
|
||||
{
|
||||
var userData = new UserItemData();
|
||||
|
||||
userData.Key = reader[0].ToString();
|
||||
// userData.UserId = reader[1].ReadGuidFromBlob();
|
||||
var userData = new UserItemData
|
||||
{
|
||||
Key = reader.GetString(0)
|
||||
};
|
||||
|
||||
if (reader.TryGetDouble(2, out var rating))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -138,13 +137,13 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||
|
||||
return new UserDataChangeInfo
|
||||
{
|
||||
UserId = userId.ToString("N", CultureInfo.InvariantCulture),
|
||||
UserId = userId,
|
||||
UserDataList = changedItems
|
||||
.DistinctBy(x => x.Id)
|
||||
.Select(i =>
|
||||
{
|
||||
var dto = _userDataManager.GetUserDataDto(i, user);
|
||||
dto.ItemId = i.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
dto.ItemId = i.Id;
|
||||
return dto;
|
||||
})
|
||||
.ToArray()
|
||||
|
|
|
@ -379,7 +379,8 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
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.SubtitleMode != SubtitlePlaybackMode.None
|
||||
&& allowRememberingSelection)
|
||||
|
@ -411,7 +412,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
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;
|
||||
// Make sure the saved index is still valid
|
||||
|
@ -434,7 +435,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
@ -19,17 +17,11 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// </summary>
|
||||
private double? _rating;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key.
|
||||
/// </summary>
|
||||
/// <value>The key.</value>
|
||||
public string Key { get; set; }
|
||||
public required string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users 0-10 rating.
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#pragma warning disable CA1002, CA2227, CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
|
@ -33,8 +31,6 @@ namespace MediaBrowser.Controller.Providers
|
|||
set => _remoteImages = value;
|
||||
}
|
||||
|
||||
public List<UserItemData> UserDataList { get; set; }
|
||||
|
||||
public List<PersonInfo> People { get; set; }
|
||||
|
||||
public bool HasMetadata { get; set; }
|
||||
|
@ -68,32 +64,5 @@ namespace MediaBrowser.Controller.Providers
|
|||
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;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
|
@ -66,12 +65,12 @@ namespace MediaBrowser.Model.Dto
|
|||
/// Gets or sets the key.
|
||||
/// </summary>
|
||||
/// <value>The key.</value>
|
||||
public string Key { get; set; }
|
||||
public required string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item identifier.
|
||||
/// </summary>
|
||||
/// <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;
|
||||
|
||||
namespace MediaBrowser.Model.Session
|
||||
|
@ -12,12 +12,12 @@ namespace MediaBrowser.Model.Session
|
|||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
public string UserId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user data list.
|
||||
/// </summary>
|
||||
/// <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.Images = tmpItem.Images;
|
||||
result.RemoteImages = tmpItem.RemoteImages;
|
||||
|
||||
if (tmpItem.UserDataList is not null)
|
||||
{
|
||||
result.UserDataList = tmpItem.UserDataList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -53,7 +53,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
|||
|
||||
var userData = new Mock<IUserDataManager>();
|
||||
userData.Setup(x => x.GetUserData(_testUser, It.IsAny<BaseItem>()))
|
||||
.Returns(new UserItemData());
|
||||
.Returns(new UserItemData()
|
||||
{
|
||||
Key = "Something"
|
||||
});
|
||||
|
||||
var directoryService = new Mock<IDirectoryService>();
|
||||
_localImageFileMetadata = new FileSystemMetadata()
|
||||
|
|
Loading…
Reference in New Issue
Block a user