diff --git a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs index 059f8c628..3c81d83cf 100644 --- a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs @@ -4,7 +4,6 @@ { public string EmailHost { get; set; } public int EmailPort { get; set; } - public bool EmailAuthentication { get; set; } public string RecipientEmail { get; set; } public string EmailUsername { get; set; } public string EmailPassword { get; set; } diff --git a/PlexRequests.Services/AvailabilityUpdateService.cs b/PlexRequests.Services/AvailabilityUpdateService.cs index cbdaeea53..c32573d7a 100644 --- a/PlexRequests.Services/AvailabilityUpdateService.cs +++ b/PlexRequests.Services/AvailabilityUpdateService.cs @@ -26,8 +26,6 @@ #endregion using System; using System.Reactive.Linq; -using System.Runtime.Remoting.Messaging; -using System.Threading.Tasks; using System.Web.Hosting; using FluentScheduler; @@ -76,7 +74,7 @@ namespace PlexRequests.Services public void Stop(bool immediate) { - throw new System.NotImplementedException(); + HostingEnvironment.UnregisterObject(this); } } diff --git a/PlexRequests.Services/Interfaces/IIntervals.cs b/PlexRequests.Services/Interfaces/IIntervals.cs index 260017689..09e13df08 100644 --- a/PlexRequests.Services/Interfaces/IIntervals.cs +++ b/PlexRequests.Services/Interfaces/IIntervals.cs @@ -30,8 +30,6 @@ namespace PlexRequests.Services.Interfaces { public interface IIntervals { - TimeSpan CriticalNotification { get; } // notification interval for critical load - TimeSpan Measurement { get; } // how often to measure TimeSpan Notification { get; } // notification interval for high load } } \ No newline at end of file diff --git a/PlexRequests.Services/UpdateInterval.cs b/PlexRequests.Services/UpdateInterval.cs index 64c65610a..876b9e379 100644 --- a/PlexRequests.Services/UpdateInterval.cs +++ b/PlexRequests.Services/UpdateInterval.cs @@ -32,9 +32,7 @@ namespace PlexRequests.Services { public class UpdateInterval : IIntervals { - public TimeSpan Measurement => TimeSpan.FromSeconds(1); - public TimeSpan CriticalNotification { get; } - public TimeSpan Notification => TimeSpan.FromMinutes(2); + public TimeSpan Notification => TimeSpan.FromMinutes(5); } } \ No newline at end of file diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index cba488a80..69a543708 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -294,6 +294,11 @@ namespace PlexRequests.UI.Modules private Response SaveEmailNotifications() { var settings = this.Bind(); + var valid = this.Validate(settings); + if (!valid.IsValid) + { + return Response.AsJson(valid.SendJsonError()); + } Log.Trace(settings.DumpJson()); var result = EmailService.SaveSettings(settings); diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index ec6b7bfdf..c60df4f92 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -161,6 +161,7 @@ + diff --git a/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs b/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs new file mode 100644 index 000000000..be5c106e7 --- /dev/null +++ b/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs @@ -0,0 +1,46 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SonarrValidator.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using FluentValidation; + +using PlexRequests.Core.SettingModels; + +namespace PlexRequests.UI.Validators +{ + public class EmailNotificationSettingsValidator : AbstractValidator + { + public EmailNotificationSettingsValidator() + { + RuleFor(request => request.EmailHost).NotEmpty().WithMessage("You must specify a Host name."); + RuleFor(request => request.EmailPort).NotEmpty().WithMessage("You must specify a Port."); + RuleFor(request => request.RecipientEmail).NotEmpty().WithMessage("You must specify a Recipient."); + RuleFor(request => request.RecipientEmail).EmailAddress().WithMessage("You must specify a valid Recipient."); + RuleFor(request => request.EmailUsername).EmailAddress().WithMessage("You must specify a valid Username."); + RuleFor(request => request.EmailUsername).NotEmpty().WithMessage("You must specify a Username."); + RuleFor(request => request.EmailPassword).NotEmpty().WithMessage("You must specify a valid password."); + } + } +} \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml b/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml index 90c17038d..405a96e25 100644 --- a/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml +++ b/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml @@ -52,21 +52,6 @@ -
-
- -
-
-
@@ -84,10 +69,45 @@
- +
+ \ No newline at end of file