Remove Emby.Notifications (#9147)

This commit is contained in:
Patrick Barron
2023-01-28 09:43:55 -05:00
committed by GitHub
parent abffd160c3
commit fec23de427
20 changed files with 0 additions and 1188 deletions

View File

@@ -1,11 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.Notifications
{
public enum NotificationLevel
{
Normal = 0,
Warning = 1,
Error = 2
}
}

View File

@@ -1,55 +0,0 @@
#pragma warning disable CA1819 // Properties should not return arrays
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Notifications
{
public class NotificationOption
{
public NotificationOption(string type)
{
Type = type;
DisabledServices = Array.Empty<string>();
DisabledMonitorUsers = Array.Empty<string>();
SendToUsers = Array.Empty<string>();
}
public NotificationOption()
{
DisabledServices = Array.Empty<string>();
DisabledMonitorUsers = Array.Empty<string>();
SendToUsers = Array.Empty<string>();
}
public string? Type { get; set; }
/// <summary>
/// Gets or sets user Ids to not monitor (it's opt out).
/// </summary>
public string[] DisabledMonitorUsers { get; set; }
/// <summary>
/// Gets or sets user Ids to send to (if SendToUserMode == Custom).
/// </summary>
public string[] SendToUsers { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="NotificationOption"/> is enabled.
/// </summary>
/// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
public bool Enabled { get; set; }
/// <summary>
/// Gets or sets the disabled services.
/// </summary>
/// <value>The disabled services.</value>
public string[] DisabledServices { get; set; }
/// <summary>
/// Gets or sets the send to user mode.
/// </summary>
/// <value>The send to user mode.</value>
public SendToUserType SendToUserMode { get; set; }
}
}

View File

@@ -1,131 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
namespace MediaBrowser.Model.Notifications
{
public class NotificationOptions
{
public NotificationOptions()
{
Options = new[]
{
new NotificationOption(NotificationType.TaskFailed.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.ServerRestartRequired.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.ApplicationUpdateAvailable.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.ApplicationUpdateInstalled.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.PluginUpdateInstalled.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.PluginUninstalled.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.InstallationFailed.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.PluginInstalled.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.PluginError.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
new NotificationOption(NotificationType.UserLockedOut.ToString())
{
Enabled = true,
SendToUserMode = SendToUserType.Admins
}
};
}
public NotificationOption[] Options { get; set; }
public NotificationOption GetOptions(string type)
{
foreach (NotificationOption i in Options)
{
if (string.Equals(type, i.Type, StringComparison.OrdinalIgnoreCase))
{
return i;
}
}
return null;
}
public bool IsEnabled(string type)
{
NotificationOption opt = GetOptions(type);
return opt is not null && opt.Enabled;
}
public bool IsServiceEnabled(string service, string notificationType)
{
NotificationOption opt = GetOptions(notificationType);
return opt is null
|| !opt.DisabledServices.Contains(service, StringComparison.OrdinalIgnoreCase);
}
public bool IsEnabledToMonitorUser(string type, Guid userId)
{
NotificationOption opt = GetOptions(type);
return opt is not null
&& opt.Enabled
&& !opt.DisabledMonitorUsers.Contains(userId.ToString("N"), StringComparison.OrdinalIgnoreCase);
}
public bool IsEnabledToSendToUser(string type, string userId, User user)
{
NotificationOption opt = GetOptions(type);
if (opt is not null && opt.Enabled)
{
if (opt.SendToUserMode == SendToUserType.All)
{
return true;
}
if (opt.SendToUserMode == SendToUserType.Admins && user.HasPermission(PermissionKind.IsAdministrator))
{
return true;
}
return opt.SendToUsers.Contains(userId, StringComparison.OrdinalIgnoreCase);
}
return false;
}
}
}

View File

@@ -1,35 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Notifications
{
public class NotificationRequest
{
public NotificationRequest()
{
UserIds = Array.Empty<Guid>();
Date = DateTime.UtcNow;
}
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public NotificationLevel Level { get; set; }
public Guid[] UserIds { get; set; }
public DateTime Date { get; set; }
/// <summary>
/// Gets or sets the corresponding type name used in configuration. Not for display.
/// </summary>
public string NotificationType { get; set; }
public SendToUserType? SendToUserMode { get; set; }
}
}

View File

@@ -1,18 +0,0 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Notifications
{
public class NotificationTypeInfo
{
public string Type { get; set; }
public string Name { get; set; }
public bool Enabled { get; set; }
public string Category { get; set; }
public bool IsBasedOnUserEvent { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.Notifications
{
public enum SendToUserType
{
All = 0,
Admins = 1,
Custom = 2
}
}