mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-25 11:36:35 +00:00
Use helper function to compare guid (#10825)
This commit is contained in:
26
src/Jellyfin.Extensions/GuidExtensions.cs
Normal file
26
src/Jellyfin.Extensions/GuidExtensions.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Jellyfin.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Guid specific extensions.
|
||||
/// </summary>
|
||||
public static class GuidExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine whether the guid is default.
|
||||
/// </summary>
|
||||
/// <param name="guid">The guid.</param>
|
||||
/// <returns>Whether the guid is the default value.</returns>
|
||||
public static bool IsEmpty(this Guid guid)
|
||||
=> guid.Equals(default);
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether the guid is null or default.
|
||||
/// </summary>
|
||||
/// <param name="guid">The guid.</param>
|
||||
/// <returns>Whether the guid is null or the default valueF.</returns>
|
||||
public static bool IsNullOrEmpty([NotNullWhen(false)] this Guid? guid)
|
||||
=> guid is null || guid.Value.IsEmpty();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Jellyfin.Extensions.Json.Converters
|
||||
{
|
||||
// null got handled higher up the call stack
|
||||
var val = value!.Value;
|
||||
if (val.Equals(default))
|
||||
if (val.IsEmpty())
|
||||
{
|
||||
writer.WriteNullValue();
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Jellyfin.LiveTv.Channels
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<Channel>> GetChannelsInternalAsync(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(default)
|
||||
var user = query.UserId.IsEmpty()
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace Jellyfin.LiveTv.Channels
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<BaseItemDto>> GetChannelsAsync(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(default)
|
||||
var user = query.UserId.IsEmpty()
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -695,7 +695,7 @@ namespace Jellyfin.LiveTv.Channels
|
||||
// Find the corresponding channel provider plugin
|
||||
var channelProvider = GetChannelProvider(channel);
|
||||
|
||||
var parentItem = query.ParentId.Equals(default)
|
||||
var parentItem = query.ParentId.IsEmpty()
|
||||
? channel
|
||||
: _libraryManager.GetItemById(query.ParentId);
|
||||
|
||||
@@ -708,7 +708,7 @@ namespace Jellyfin.LiveTv.Channels
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (query.ParentId.Equals(default))
|
||||
if (query.ParentId.IsEmpty())
|
||||
{
|
||||
query.Parent = channel;
|
||||
}
|
||||
|
||||
@@ -1992,7 +1992,7 @@ namespace Jellyfin.LiveTv.EmbyTV
|
||||
await writer.WriteElementStringAsync(null, "genre", null, genre).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var people = item.Id.Equals(default) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
|
||||
var people = item.Id.IsEmpty() ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
|
||||
|
||||
var directors = people
|
||||
.Where(i => i.IsType(PersonKind.Director))
|
||||
@@ -2317,7 +2317,7 @@ namespace Jellyfin.LiveTv.EmbyTV
|
||||
{
|
||||
string channelId = seriesTimer.RecordAnyChannel ? null : seriesTimer.ChannelId;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(default))
|
||||
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.IsEmpty())
|
||||
{
|
||||
if (!tempChannelCache.TryGetValue(parent.ChannelId, out LiveTvChannel channel))
|
||||
{
|
||||
@@ -2376,7 +2376,7 @@ namespace Jellyfin.LiveTv.EmbyTV
|
||||
{
|
||||
string channelId = null;
|
||||
|
||||
if (!programInfo.ChannelId.Equals(default))
|
||||
if (!programInfo.ChannelId.IsEmpty())
|
||||
{
|
||||
if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out LiveTvChannel channel))
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
@@ -456,7 +457,7 @@ namespace Jellyfin.LiveTv
|
||||
info.Id = timer.ExternalId;
|
||||
}
|
||||
|
||||
if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
|
||||
if (!dto.ChannelId.IsEmpty() && string.IsNullOrEmpty(info.ChannelId))
|
||||
{
|
||||
var channel = _libraryManager.GetItemById(dto.ChannelId);
|
||||
|
||||
@@ -522,7 +523,7 @@ namespace Jellyfin.LiveTv
|
||||
info.Id = timer.ExternalId;
|
||||
}
|
||||
|
||||
if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
|
||||
if (!dto.ChannelId.IsEmpty() && string.IsNullOrEmpty(info.ChannelId))
|
||||
{
|
||||
var channel = _libraryManager.GetItemById(dto.ChannelId);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Data.Events;
|
||||
using Jellyfin.Extensions;
|
||||
using Jellyfin.LiveTv.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Progress;
|
||||
@@ -150,7 +151,7 @@ namespace Jellyfin.LiveTv
|
||||
|
||||
public QueryResult<BaseItem> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = query.UserId.Equals(default)
|
||||
var user = query.UserId.IsEmpty()
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -1245,7 +1246,7 @@ namespace Jellyfin.LiveTv
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (itemId.Equals(default))
|
||||
if (itemId.IsEmpty())
|
||||
{
|
||||
// Somehow some invalid data got into the db. It probably predates the boundary checking
|
||||
continue;
|
||||
@@ -1504,7 +1505,7 @@ namespace Jellyfin.LiveTv
|
||||
|
||||
public async Task<QueryResult<BaseItemDto>> GetRecordingsAsync(RecordingQuery query, DtoOptions options)
|
||||
{
|
||||
var user = query.UserId.Equals(default)
|
||||
var user = query.UserId.IsEmpty()
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user