aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Notifications
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model/Notifications')
-rw-r--r--MediaBrowser.Model/Notifications/NotificationLevel.cs2
-rw-r--r--MediaBrowser.Model/Notifications/NotificationOption.cs31
-rw-r--r--MediaBrowser.Model/Notifications/NotificationOptions.cs63
-rw-r--r--MediaBrowser.Model/Notifications/NotificationRequest.cs17
-rw-r--r--MediaBrowser.Model/Notifications/NotificationType.cs3
-rw-r--r--MediaBrowser.Model/Notifications/NotificationTypeInfo.cs3
-rw-r--r--MediaBrowser.Model/Notifications/SendToUserType.cs2
7 files changed, 71 insertions, 50 deletions
diff --git a/MediaBrowser.Model/Notifications/NotificationLevel.cs b/MediaBrowser.Model/Notifications/NotificationLevel.cs
index 6a838b125..14fead3f0 100644
--- a/MediaBrowser.Model/Notifications/NotificationLevel.cs
+++ b/MediaBrowser.Model/Notifications/NotificationLevel.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
namespace MediaBrowser.Model.Notifications
{
public enum NotificationLevel
diff --git a/MediaBrowser.Model/Notifications/NotificationOption.cs b/MediaBrowser.Model/Notifications/NotificationOption.cs
index 51a07370f..58aecb3d3 100644
--- a/MediaBrowser.Model/Notifications/NotificationOption.cs
+++ b/MediaBrowser.Model/Notifications/NotificationOption.cs
@@ -1,18 +1,36 @@
+#pragma warning disable CA1819 // Properties should not return arrays
+#pragma warning disable CS1591
+
using System;
namespace MediaBrowser.Model.Notifications
{
public class NotificationOption
{
- public string Type { get; set; }
+ 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>
- /// User Ids to not monitor (it's opt out)
+ /// Gets or sets user Ids to not monitor (it's opt out).
/// </summary>
public string[] DisabledMonitorUsers { get; set; }
/// <summary>
- /// User Ids to send to (if SendToUserMode == Custom)
+ /// Gets or sets user Ids to send to (if SendToUserMode == Custom).
/// </summary>
public string[] SendToUsers { get; set; }
@@ -33,12 +51,5 @@ namespace MediaBrowser.Model.Notifications
/// </summary>
/// <value>The send to user mode.</value>
public SendToUserType SendToUserMode { get; set; }
-
- public NotificationOption()
- {
- DisabledServices = Array.Empty<string>();
- DisabledMonitorUsers = Array.Empty<string>();
- SendToUsers = Array.Empty<string>();
- }
}
}
diff --git a/MediaBrowser.Model/Notifications/NotificationOptions.cs b/MediaBrowser.Model/Notifications/NotificationOptions.cs
index f48b5ee7f..09beb2ef7 100644
--- a/MediaBrowser.Model/Notifications/NotificationOptions.cs
+++ b/MediaBrowser.Model/Notifications/NotificationOptions.cs
@@ -1,86 +1,84 @@
+#nullable disable
+#pragma warning disable CS1591
+
using System;
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.Users;
+using System.Linq;
+using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
namespace MediaBrowser.Model.Notifications
{
public class NotificationOptions
{
- public NotificationOption[] Options { get; set; }
-
public NotificationOptions()
{
Options = new[]
{
- new NotificationOption
+ new NotificationOption(NotificationType.TaskFailed.ToString())
{
- Type = NotificationType.TaskFailed.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.ServerRestartRequired.ToString())
{
- Type = NotificationType.ServerRestartRequired.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.ApplicationUpdateAvailable.ToString())
{
- Type = NotificationType.ApplicationUpdateAvailable.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.ApplicationUpdateInstalled.ToString())
{
- Type = NotificationType.ApplicationUpdateInstalled.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.PluginUpdateInstalled.ToString())
{
- Type = NotificationType.PluginUpdateInstalled.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.PluginUninstalled.ToString())
{
- Type = NotificationType.PluginUninstalled.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.InstallationFailed.ToString())
{
- Type = NotificationType.InstallationFailed.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.PluginInstalled.ToString())
{
- Type = NotificationType.PluginInstalled.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.PluginError.ToString())
{
- Type = NotificationType.PluginError.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
},
- new NotificationOption
+ new NotificationOption(NotificationType.UserLockedOut.ToString())
{
- Type = NotificationType.UserLockedOut.ToString(),
Enabled = true,
SendToUserMode = SendToUserType.Admins
}
};
}
+ public NotificationOption[] Options { get; set; }
+
public NotificationOption GetOptions(string type)
{
foreach (NotificationOption i in Options)
{
- if (StringHelper.EqualsIgnoreCase(type, i.Type)) return i;
+ if (string.Equals(type, i.Type, StringComparison.OrdinalIgnoreCase))
+ {
+ return i;
+ }
}
+
return null;
}
@@ -95,19 +93,20 @@ namespace MediaBrowser.Model.Notifications
{
NotificationOption opt = GetOptions(notificationType);
- return opt == null ||
- !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service);
+ return opt == null
+ || !opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase);
}
public bool IsEnabledToMonitorUser(string type, Guid userId)
{
NotificationOption opt = GetOptions(type);
- return opt != null && opt.Enabled &&
- !ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId.ToString(""));
+ return opt != null
+ && opt.Enabled
+ && !opt.DisabledMonitorUsers.Contains(userId.ToString("N"), StringComparer.OrdinalIgnoreCase);
}
- public bool IsEnabledToSendToUser(string type, string userId, UserPolicy userPolicy)
+ public bool IsEnabledToSendToUser(string type, string userId, User user)
{
NotificationOption opt = GetOptions(type);
@@ -118,12 +117,12 @@ namespace MediaBrowser.Model.Notifications
return true;
}
- if (opt.SendToUserMode == SendToUserType.Admins && userPolicy.IsAdministrator)
+ if (opt.SendToUserMode == SendToUserType.Admins && user.HasPermission(PermissionKind.IsAdministrator))
{
return true;
}
- return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
+ return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase);
}
return false;
diff --git a/MediaBrowser.Model/Notifications/NotificationRequest.cs b/MediaBrowser.Model/Notifications/NotificationRequest.cs
index 5a2634e73..622c50cd8 100644
--- a/MediaBrowser.Model/Notifications/NotificationRequest.cs
+++ b/MediaBrowser.Model/Notifications/NotificationRequest.cs
@@ -1,9 +1,18 @@
+#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; }
@@ -17,16 +26,10 @@ namespace MediaBrowser.Model.Notifications
public DateTime Date { get; set; }
/// <summary>
- /// The corresponding type name used in configuration. Not for display.
+ /// Gets or sets the corresponding type name used in configuration. Not for display.
/// </summary>
public string NotificationType { get; set; }
public SendToUserType? SendToUserMode { get; set; }
-
- public NotificationRequest()
- {
- UserIds = Array.Empty<Guid>();
- Date = DateTime.UtcNow;
- }
}
}
diff --git a/MediaBrowser.Model/Notifications/NotificationType.cs b/MediaBrowser.Model/Notifications/NotificationType.cs
index 38b519a14..a8b257b8d 100644
--- a/MediaBrowser.Model/Notifications/NotificationType.cs
+++ b/MediaBrowser.Model/Notifications/NotificationType.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
namespace MediaBrowser.Model.Notifications
{
public enum NotificationType
@@ -16,7 +18,6 @@ namespace MediaBrowser.Model.Notifications
NewLibraryContent,
ServerRestartRequired,
TaskFailed,
- CameraImageUploaded,
UserLockedOut
}
}
diff --git a/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs b/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs
index ff957e644..402fbe81a 100644
--- a/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs
+++ b/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs
@@ -1,3 +1,6 @@
+#nullable disable
+#pragma warning disable CS1591
+
namespace MediaBrowser.Model.Notifications
{
public class NotificationTypeInfo
diff --git a/MediaBrowser.Model/Notifications/SendToUserType.cs b/MediaBrowser.Model/Notifications/SendToUserType.cs
index 9f63d24bf..65fc4e1ab 100644
--- a/MediaBrowser.Model/Notifications/SendToUserType.cs
+++ b/MediaBrowser.Model/Notifications/SendToUserType.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
namespace MediaBrowser.Model.Notifications
{
public enum SendToUserType