Enable nullable for Jellyfin.Data and remove unnecessary attributes

This commit is contained in:
Patrick Barron 2021-03-06 17:43:01 -05:00
parent 287dab4655
commit f638ee6b09
44 changed files with 93 additions and 111 deletions

View File

@ -352,8 +352,13 @@ namespace Emby.Drawing
} }
/// <inheritdoc /> /// <inheritdoc />
public string GetImageCacheTag(User user) public string? GetImageCacheTag(User user)
{ {
if (user.ProfileImage == null)
{
return null;
}
return (user.ProfileImage.Path + user.ProfileImage.LastModified.Ticks).GetMD5() return (user.ProfileImage.Path + user.ProfileImage.LastModified.Ticks).GetMD5()
.ToString("N", CultureInfo.InvariantCulture); .ToString("N", CultureInfo.InvariantCulture);
} }

View File

@ -196,6 +196,11 @@ namespace Jellyfin.Api.Controllers
} }
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user?.ProfileImage == null)
{
return NoContent();
}
try try
{ {
System.IO.File.Delete(user.ProfileImage.Path); System.IO.File.Delete(user.ProfileImage.Path);
@ -235,6 +240,11 @@ namespace Jellyfin.Api.Controllers
} }
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user?.ProfileImage == null)
{
return NoContent();
}
try try
{ {
System.IO.File.Delete(user.ProfileImage.Path); System.IO.File.Delete(user.ProfileImage.Path);
@ -1469,7 +1479,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex) [FromQuery] int? imageIndex)
{ {
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
if (user == null) if (user?.ProfileImage == null)
{ {
return NotFound(); return NotFound();
} }

View File

@ -132,7 +132,10 @@ namespace Jellyfin.Api.Controllers
{ {
var user = _userManager.Users.First(); var user = _userManager.Users.First();
user.Username = startupUserDto.Name; if (startupUserDto.Name != null)
{
user.Username = startupUserDto.Name;
}
await _userManager.UpdateUserAsync(user).ConfigureAwait(false); await _userManager.UpdateUserAsync(user).ConfigureAwait(false);

View File

@ -1,5 +1,4 @@
using System; using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization; using System.Xml.Serialization;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
@ -33,8 +32,6 @@ namespace Jellyfin.Data.Entities
/// Identity, Indexed, Required. /// Identity, Indexed, Required.
/// </remarks> /// </remarks>
[XmlIgnore] [XmlIgnore]
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; } public int Id { get; protected set; }
@ -42,28 +39,24 @@ namespace Jellyfin.Data.Entities
/// Gets or sets the id of the associated user. /// Gets or sets the id of the associated user.
/// </summary> /// </summary>
[XmlIgnore] [XmlIgnore]
[Required]
public Guid UserId { get; protected set; } public Guid UserId { get; protected set; }
/// <summary> /// <summary>
/// Gets or sets the day of week. /// Gets or sets the day of week.
/// </summary> /// </summary>
/// <value>The day of week.</value> /// <value>The day of week.</value>
[Required]
public DynamicDayOfWeek DayOfWeek { get; set; } public DynamicDayOfWeek DayOfWeek { get; set; }
/// <summary> /// <summary>
/// Gets or sets the start hour. /// Gets or sets the start hour.
/// </summary> /// </summary>
/// <value>The start hour.</value> /// <value>The start hour.</value>
[Required]
public double StartHour { get; set; } public double StartHour { get; set; }
/// <summary> /// <summary>
/// Gets or sets the end hour. /// Gets or sets the end hour.
/// </summary> /// </summary>
/// <value>The end hour.</value> /// <value>The end hour.</value>
[Required]
public double EndHour { get; set; } public double EndHour { get; set; }
/// <summary> /// <summary>

View File

@ -50,7 +50,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 512. /// Required, Max length = 512.
/// </remarks> /// </remarks>
[Required]
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Name { get; set; } public string Name { get; set; }
@ -63,7 +62,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Overview { get; set; } public string? Overview { get; set; }
/// <summary> /// <summary>
/// Gets or sets the short overview. /// Gets or sets the short overview.
@ -73,7 +72,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string ShortOverview { get; set; } public string? ShortOverview { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type. /// Gets or sets the type.
@ -81,7 +80,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 256. /// Required, Max length = 256.
/// </remarks> /// </remarks>
[Required]
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string Type { get; set; } public string Type { get; set; }
@ -102,7 +100,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string ItemId { get; set; } public string? ItemId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date created. This should be in UTC. /// Gets or sets the date created. This should be in UTC.

View File

@ -57,7 +57,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -68,7 +67,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Key { get; set; } public string Key { get; set; }
/// <summary> /// <summary>
@ -77,7 +75,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Value { get; set; } public string Value { get; set; }
} }
} }

View File

@ -30,8 +30,6 @@ namespace Jellyfin.Data.Entities
SkipBackwardLength = 10000; SkipBackwardLength = 10000;
ScrollDirection = ScrollDirection.Horizontal; ScrollDirection = ScrollDirection.Horizontal;
ChromecastVersion = ChromecastVersion.Stable; ChromecastVersion = ChromecastVersion.Stable;
DashboardTheme = string.Empty;
TvHome = string.Empty;
HomeSections = new HashSet<HomeSection>(); HomeSections = new HashSet<HomeSection>();
} }
@ -67,7 +65,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -138,14 +135,14 @@ namespace Jellyfin.Data.Entities
/// </summary> /// </summary>
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string DashboardTheme { get; set; } public string? DashboardTheme { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tv home screen. /// Gets or sets the tv home screen.
/// </summary> /// </summary>
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string TvHome { get; set; } public string? TvHome { get; set; }
/// <summary> /// <summary>
/// Gets or sets the home sections. /// Gets or sets the home sections.

View File

@ -46,7 +46,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Name { get; set; } public string Name { get; set; }

View File

@ -15,7 +15,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Identity. Required. /// Identity. Required.
/// </remarks> /// </remarks>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; } public int Id { get; protected set; }

View File

@ -39,7 +39,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
[MaxLength(512)] [MaxLength(512)]
[StringLength(512)] [StringLength(512)]
public string Path { get; set; } public string Path { get; set; }

View File

@ -59,7 +59,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. Max Length = 32. /// Required. Max Length = 32.
/// </remarks> /// </remarks>
[Required]
[MaxLength(32)] [MaxLength(32)]
[StringLength(32)] [StringLength(32)]
public string Client { get; set; } public string Client { get; set; }
@ -99,7 +98,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
[MaxLength(64)] [MaxLength(64)]
[StringLength(64)] [StringLength(64)]
public string SortBy { get; set; } public string SortBy { get; set; }

View File

@ -44,7 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Path { get; set; } public string Path { get; set; }

View File

@ -1,7 +1,6 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -32,7 +31,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Publishers { get; protected set; } public virtual ICollection<Company> Publishers { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Publishers; public ICollection<Company> Companies => Publishers;
} }
} }

View File

@ -45,7 +45,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the language. /// Gets or sets the language.
@ -54,7 +54,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// Required, Min length = 3, Max length = 3 /// Required, Min length = 3, Max length = 3
/// ISO-639-3 3-character language codes. /// ISO-639-3 3-character language codes.
/// </remarks> /// </remarks>
[Required]
[MinLength(3)] [MinLength(3)]
[MaxLength(3)] [MaxLength(3)]
[StringLength(3)] [StringLength(3)]

View File

@ -37,7 +37,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[ConcurrencyCheck] [ConcurrencyCheck]

View File

@ -9,6 +9,15 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
public class CollectionItem : IHasConcurrencyToken public class CollectionItem : IHasConcurrencyToken
{ {
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary>
/// <param name="libraryItem">The library item.</param>
public CollectionItem(LibraryItem libraryItem)
{
LibraryItem = libraryItem;
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -36,7 +45,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// TODO check if this properly updated Dependant and has the proper principal relationship. /// TODO check if this properly updated Dependant and has the proper principal relationship.
/// </remarks> /// </remarks>
public virtual CollectionItem Next { get; set; } public virtual CollectionItem? Next { get; set; }
/// <summary> /// <summary>
/// Gets or sets the previous item in the collection. /// Gets or sets the previous item in the collection.
@ -44,7 +53,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// TODO check if this properly updated Dependant and has the proper principal relationship. /// TODO check if this properly updated Dependant and has the proper principal relationship.
/// </remarks> /// </remarks>
public virtual CollectionItem Previous { get; set; } public virtual CollectionItem? Previous { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

View File

@ -18,6 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
public Company() public Company()
{ {
CompanyMetadata = new HashSet<CompanyMetadata>(); CompanyMetadata = new HashSet<CompanyMetadata>();
ChildCompanies = new HashSet<Company>();
} }
/// <summary> /// <summary>
@ -44,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> ChildCompanies { get; protected set; } public virtual ICollection<Company> ChildCompanies { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => ChildCompanies; public ICollection<Company> Companies => ChildCompanies;
/// <inheritdoc /> /// <inheritdoc />

View File

@ -24,7 +24,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Description { get; set; } public string? Description { get; set; }
/// <summary> /// <summary>
/// Gets or sets the headquarters. /// Gets or sets the headquarters.
@ -34,7 +34,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Headquarters { get; set; } public string? Headquarters { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -44,7 +44,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets the homepage. /// Gets or sets the homepage.
@ -54,6 +54,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Homepage { get; set; } public string? Homepage { get; set; }
} }
} }

View File

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>

View File

@ -24,7 +24,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -34,7 +34,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -44,6 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
} }
} }

View File

@ -33,7 +33,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Indexed, Required, Max length = 255. /// Indexed, Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Name { get; set; } public string Name { get; set; }

View File

@ -57,7 +57,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Title { get; set; } public string Title { get; set; }
@ -70,7 +69,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string OriginalTitle { get; set; } public string? OriginalTitle { get; set; }
/// <summary> /// <summary>
/// Gets or sets the sort title. /// Gets or sets the sort title.
@ -80,7 +79,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string SortTitle { get; set; } public string? SortTitle { get; set; }
/// <summary> /// <summary>
/// Gets or sets the language. /// Gets or sets the language.
@ -89,7 +88,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// Required, Min length = 3, Max length = 3. /// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes. /// ISO-639-3 3-character language codes.
/// </remarks> /// </remarks>
[Required]
[MinLength(3)] [MinLength(3)]
[MaxLength(3)] [MaxLength(3)]
[StringLength(3)] [StringLength(3)]

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,14 +13,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Library"/> class. /// Initializes a new instance of the <see cref="Library"/> class.
/// </summary> /// </summary>
/// <param name="name">The name of the library.</param> /// <param name="name">The name of the library.</param>
public Library(string name) /// <param name="path">The path of the library.</param>
public Library(string name, string path)
{ {
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
Path = path;
} }
/// <summary> /// <summary>
@ -39,7 +35,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 128. /// Required, Max length = 128.
/// </remarks> /// </remarks>
[Required]
[MaxLength(128)] [MaxLength(128)]
[StringLength(128)] [StringLength(128)]
public string Name { get; set; } public string Name { get; set; }
@ -50,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public string Path { get; set; } public string Path { get; set; }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -44,7 +44,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public virtual Library Library { get; set; } public virtual Library Library { get; set; }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -47,7 +47,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Path { get; set; } public string Path { get; set; }

View File

@ -39,7 +39,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }

View File

@ -14,7 +14,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class. /// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary> /// </summary>
/// <param name="providerId">The provider id.</param> /// <param name="providerId">The provider id.</param>
public MetadataProviderId(string providerId) /// <param name="metadataProvider">The metadata provider.</param>
public MetadataProviderId(string providerId, MetadataProvider metadataProvider)
{ {
if (string.IsNullOrEmpty(providerId)) if (string.IsNullOrEmpty(providerId))
{ {
@ -22,6 +23,7 @@ namespace Jellyfin.Data.Entities.Libraries
} }
ProviderId = providerId; ProviderId = providerId;
MetadataProvider = metadataProvider;
} }
/// <summary> /// <summary>
@ -39,7 +41,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string ProviderId { get; set; } public string ProviderId { get; set; }

View File

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -30,7 +29,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -40,7 +39,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -50,7 +49,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -60,7 +59,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets the studios that produced this movie. /// Gets or sets the studios that produced this movie.
@ -68,7 +67,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Studios { get; protected set; } public virtual ICollection<Company> Studios { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Studios; public ICollection<Company> Companies => Studios;
} }
} }

View File

@ -28,7 +28,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Barcode { get; set; } public string? Barcode { get; set; }
/// <summary> /// <summary>
/// Gets or sets the label number. /// Gets or sets the label number.
@ -38,7 +38,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string LabelNumber { get; set; } public string? LabelNumber { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -48,7 +48,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets a collection containing the labels. /// Gets or sets a collection containing the labels.

View File

@ -46,7 +46,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }
@ -59,7 +58,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(256)] [MaxLength(256)]
[StringLength(256)] [StringLength(256)]
public string SourceId { get; set; } public string? SourceId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date added. /// Gets or sets the date added.

View File

@ -17,9 +17,12 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="PersonRole"/> class. /// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary> /// </summary>
/// <param name="type">The role type.</param> /// <param name="type">The role type.</param>
public PersonRole(PersonRoleType type) /// <param name="person">The person.</param>
public PersonRole(PersonRoleType type, Person person)
{ {
Type = type; Type = type;
Person = person;
Artwork = new HashSet<Artwork>();
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
@ -40,7 +43,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Role { get; set; } public string? Role { get; set; }
/// <summary> /// <summary>
/// Gets or sets the person's role type. /// Gets or sets the person's role type.
@ -60,7 +63,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required]
public virtual Person Person { get; set; } public virtual Person Person { get; set; }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -48,7 +48,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// Gets or sets the rating type. /// Gets or sets the rating type.
/// If this is <c>null</c> it's the internal user rating. /// If this is <c>null</c> it's the internal user rating.
/// </summary> /// </summary>
public virtual RatingSource RatingType { get; set; } public virtual RatingSource? RatingType { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

View File

@ -37,7 +37,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the minimum value. /// Gets or sets the minimum value.
@ -62,7 +62,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Gets or sets the metadata source. /// Gets or sets the metadata source.
/// </summary> /// </summary>
public virtual MetadataProviderId Source { get; set; } public virtual MetadataProviderId? Source { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void OnSavingChanges() public void OnSavingChanges()

View File

@ -45,7 +45,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// <remarks> /// <remarks>
/// Required, Max length = 1024. /// Required, Max length = 1024.
/// </remarks> /// </remarks>
[Required]
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Name { get; set; } public string Name { get; set; }

View File

@ -24,6 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
} }
} }

View File

@ -30,7 +30,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Outline { get; set; } public string? Outline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plot. /// Gets or sets the plot.
@ -40,7 +40,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Plot { get; set; } public string? Plot { get; set; }
/// <summary> /// <summary>
/// Gets or sets the tagline. /// Gets or sets the tagline.
@ -50,7 +50,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(1024)] [MaxLength(1024)]
[StringLength(1024)] [StringLength(1024)]
public string Tagline { get; set; } public string? Tagline { get; set; }
/// <summary> /// <summary>
/// Gets or sets the country code. /// Gets or sets the country code.
@ -60,7 +60,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </remarks> /// </remarks>
[MaxLength(2)] [MaxLength(2)]
[StringLength(2)] [StringLength(2)]
public string Country { get; set; } public string? Country { get; set; }
/// <summary> /// <summary>
/// Gets or sets a collection containing the networks. /// Gets or sets a collection containing the networks.
@ -68,7 +68,6 @@ namespace Jellyfin.Data.Entities.Libraries
public virtual ICollection<Company> Networks { get; protected set; } public virtual ICollection<Company> Networks { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
[NotMapped]
public ICollection<Company> Companies => Networks; public ICollection<Company> Companies => Networks;
} }
} }

View File

@ -46,7 +46,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 65535. /// Required, Max length = 65535.
/// </remarks> /// </remarks>
[Required]
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Value { get; set; } public string Value { get; set; }

View File

@ -51,6 +51,7 @@ namespace Jellyfin.Data.Entities
PasswordResetProviderId = passwordResetProviderId; PasswordResetProviderId = passwordResetProviderId;
AccessSchedules = new HashSet<AccessSchedule>(); AccessSchedules = new HashSet<AccessSchedule>();
DisplayPreferences = new HashSet<DisplayPreferences>();
ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>(); ItemDisplayPreferences = new HashSet<ItemDisplayPreferences>();
// Groups = new HashSet<Group>(); // Groups = new HashSet<Group>();
Permissions = new HashSet<Permission>(); Permissions = new HashSet<Permission>();
@ -92,7 +93,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string Username { get; set; } public string Username { get; set; }
@ -105,7 +105,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string Password { get; set; } public string? Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user's easy password, or <c>null</c> if none is set. /// Gets or sets the user's easy password, or <c>null</c> if none is set.
@ -115,7 +115,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(65535)] [MaxLength(65535)]
[StringLength(65535)] [StringLength(65535)]
public string EasyPassword { get; set; } public string? EasyPassword { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the user must update their password. /// Gets or sets a value indicating whether the user must update their password.
@ -133,7 +133,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string AudioLanguagePreference { get; set; } public string? AudioLanguagePreference { get; set; }
/// <summary> /// <summary>
/// Gets or sets the authentication provider id. /// Gets or sets the authentication provider id.
@ -141,7 +141,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string AuthenticationProviderId { get; set; } public string AuthenticationProviderId { get; set; }
@ -152,7 +151,6 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required, Max length = 255. /// Required, Max length = 255.
/// </remarks> /// </remarks>
[Required]
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string PasswordResetProviderId { get; set; } public string PasswordResetProviderId { get; set; }
@ -209,7 +207,7 @@ namespace Jellyfin.Data.Entities
/// </remarks> /// </remarks>
[MaxLength(255)] [MaxLength(255)]
[StringLength(255)] [StringLength(255)]
public string SubtitleLanguagePreference { get; set; } public string? SubtitleLanguagePreference { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether missing episodes should be displayed. /// Gets or sets a value indicating whether missing episodes should be displayed.
@ -304,7 +302,7 @@ namespace Jellyfin.Data.Entities
/// Gets or sets the user's profile image. Can be <c>null</c>. /// Gets or sets the user's profile image. Can be <c>null</c>.
/// </summary> /// </summary>
// [ForeignKey("UserId")] // [ForeignKey("UserId")]
public virtual ImageInfo ProfileImage { get; set; } public virtual ImageInfo? ProfileImage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user's display preferences. /// Gets or sets the user's display preferences.
@ -312,8 +310,7 @@ namespace Jellyfin.Data.Entities
/// <remarks> /// <remarks>
/// Required. /// Required.
/// </remarks> /// </remarks>
[Required] public virtual ICollection<DisplayPreferences> DisplayPreferences { get; set; }
public virtual DisplayPreferences DisplayPreferences { get; set; }
/// <summary> /// <summary>
/// Gets or sets the level of sync play permissions this user has. /// Gets or sets the level of sync play permissions this user has.

View File

@ -5,6 +5,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols> <IncludeSymbols>true</IncludeSymbols>

View File

@ -86,7 +86,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return name; return name;
} }
private static string? GetPlaybackNotificationType(string mediaType) private static string GetPlaybackNotificationType(string mediaType)
{ {
if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{ {
@ -98,7 +98,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return NotificationType.VideoPlayback.ToString(); return NotificationType.VideoPlayback.ToString();
} }
return null; return "Playback";
} }
} }
} }

View File

@ -184,8 +184,8 @@ namespace Jellyfin.Server.Implementations.Users
var user = new User( var user = new User(
name, name,
_defaultAuthenticationProvider.GetType().FullName, _defaultAuthenticationProvider.GetType().FullName!,
_defaultPasswordResetProvider.GetType().FullName) _defaultPasswordResetProvider.GetType().FullName!)
{ {
InternalId = max + 1 InternalId = max + 1
}; };
@ -444,7 +444,7 @@ namespace Jellyfin.Server.Implementations.Users
{ {
var providerId = authenticationProvider.GetType().FullName; var providerId = authenticationProvider.GetType().FullName;
if (!string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase)) if (providerId != null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
{ {
user.AuthenticationProviderId = providerId; user.AuthenticationProviderId = providerId;
await UpdateUserAsync(user).ConfigureAwait(false); await UpdateUserAsync(user).ConfigureAwait(false);

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
using Emby.Server.Implementations.Data; using Emby.Server.Implementations.Data;
using Emby.Server.Implementations.Serialization; using Emby.Server.Implementations.Serialization;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
@ -104,7 +102,7 @@ namespace Jellyfin.Server.Migrations.Routines
_ => policy.LoginAttemptsBeforeLockout _ => policy.LoginAttemptsBeforeLockout
}; };
var user = new User(mockup.Name, policy.AuthenticationProviderId, policy.PasswordResetProviderId) var user = new User(mockup.Name, policy.AuthenticationProviderId!, policy.PasswordResetProviderId!)
{ {
Id = entry[1].ReadGuidFromBlob(), Id = entry[1].ReadGuidFromBlob(),
InternalId = entry[0].ToInt64(), InternalId = entry[0].ToInt64(),

View File

@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Drawing
string GetImageCacheTag(BaseItem item, ChapterInfo info); string GetImageCacheTag(BaseItem item, ChapterInfo info);
string GetImageCacheTag(User user); string? GetImageCacheTag(User user);
/// <summary> /// <summary>
/// Processes the image. /// Processes the image.

View File

@ -26,8 +26,8 @@ namespace Jellyfin.Api.Tests
{ {
var user = new User( var user = new User(
"jellyfin", "jellyfin",
typeof(DefaultAuthenticationProvider).FullName, typeof(DefaultAuthenticationProvider).FullName!,
typeof(DefaultPasswordResetProvider).FullName); typeof(DefaultPasswordResetProvider).FullName!);
// Set administrator flag. // Set administrator flag.
user.SetPermission(PermissionKind.IsAdministrator, role.Equals(UserRoles.Administrator, StringComparison.OrdinalIgnoreCase)); user.SetPermission(PermissionKind.IsAdministrator, role.Equals(UserRoles.Administrator, StringComparison.OrdinalIgnoreCase));