From a7ba1a6454687970919ac032f8c7c5bc1b1b4459 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 22 Apr 2023 20:18:22 -0500 Subject: [PATCH] Update SixLabors.ImageSharp, MailKit, DryIoc libraries Closes #8282 Co-Authored-By: Stepan Goremykin <25577658+goremykin@users.noreply.github.com> --- src/NzbDrone.Common/Radarr.Common.csproj | 2 +- src/NzbDrone.Core/MediaCover/ImageResizer.cs | 8 +- .../Notifications/Email/Email.cs | 86 +++++++++---------- .../Notifications/Email/EmailSettings.cs | 3 +- src/NzbDrone.Core/Radarr.Core.csproj | 4 +- src/NzbDrone.Host/Radarr.Host.csproj | 4 +- src/NzbDrone.Update/Radarr.Update.csproj | 4 +- 7 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/NzbDrone.Common/Radarr.Common.csproj b/src/NzbDrone.Common/Radarr.Common.csproj index e530bcb54..9928c9e3f 100644 --- a/src/NzbDrone.Common/Radarr.Common.csproj +++ b/src/NzbDrone.Common/Radarr.Common.csproj @@ -4,7 +4,7 @@ ISMUSL - + diff --git a/src/NzbDrone.Core/MediaCover/ImageResizer.cs b/src/NzbDrone.Core/MediaCover/ImageResizer.cs index ec2eefa78..c2f85c209 100644 --- a/src/NzbDrone.Core/MediaCover/ImageResizer.cs +++ b/src/NzbDrone.Core/MediaCover/ImageResizer.cs @@ -42,11 +42,9 @@ namespace NzbDrone.Core.MediaCover try { - using (var image = Image.Load(source)) - { - image.Mutate(x => x.Resize(0, height)); - image.Save(destination); - } + using var image = Image.Load(source); + image.Mutate(x => x.Resize(0, height)); + image.Save(destination); } catch { diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 7ab45ce1b..a92b9c67a 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -83,23 +83,6 @@ namespace NzbDrone.Core.Notifications.Email return new ValidationResult(failures); } - public ValidationFailure Test(EmailSettings settings) - { - const string body = "Success! You have properly configured your email notification settings"; - - try - { - SendEmail(settings, "Radarr - Test Notification", body); - } - catch (Exception ex) - { - _logger.Error(ex, "Unable to send test email"); - return new ValidationFailure("Server", "Unable to send test email"); - } - - return null; - } - private void SendEmail(EmailSettings settings, string subject, string body, bool htmlBody = false) { var email = new MimeMessage(); @@ -129,52 +112,67 @@ namespace NzbDrone.Core.Notifications.Email throw; } - _logger.Debug("Finished sending email. Subject: {0}", email.Subject); + _logger.Debug("Finished sending email. Subject: {0}", subject); } private void Send(MimeMessage email, EmailSettings settings) { - using (var client = new SmtpClient()) - { - client.Timeout = 10000; + using var client = new SmtpClient(); + client.Timeout = 10000; - var serverOption = SecureSocketOptions.Auto; + var serverOption = SecureSocketOptions.Auto; - if (settings.RequireEncryption) + if (settings.RequireEncryption) + { + if (settings.Port == 465) + { + serverOption = SecureSocketOptions.SslOnConnect; + } + else { - if (settings.Port == 465) - { - serverOption = SecureSocketOptions.SslOnConnect; - } - else - { - serverOption = SecureSocketOptions.StartTls; - } + serverOption = SecureSocketOptions.StartTls; } + } - client.ServerCertificateValidationCallback = _certificateValidationService.ShouldByPassValidationError; + client.ServerCertificateValidationCallback = _certificateValidationService.ShouldByPassValidationError; - _logger.Debug("Connecting to mail server"); + _logger.Debug("Connecting to mail server"); - client.Connect(settings.Server, settings.Port, serverOption); + client.Connect(settings.Server, settings.Port, serverOption); - if (!string.IsNullOrWhiteSpace(settings.Username)) - { - _logger.Debug("Authenticating to mail server"); + if (!string.IsNullOrWhiteSpace(settings.Username)) + { + _logger.Debug("Authenticating to mail server"); - client.Authenticate(settings.Username, settings.Password); - } + client.Authenticate(settings.Username, settings.Password); + } + + _logger.Debug("Sending to mail server"); - _logger.Debug("Sending to mail server"); + client.Send(email); - client.Send(email); + _logger.Debug("Sent to mail server, disconnecting"); - _logger.Debug("Sent to mail server, disconnecting"); + client.Disconnect(true); - client.Disconnect(true); + _logger.Debug("Disconnecting from mail server"); + } + + public ValidationFailure Test(EmailSettings settings) + { + const string body = "Success! You have properly configured your email notification settings"; - _logger.Debug("Disconnecting from mail server"); + try + { + SendEmail(settings, "Radarr - Test Notification", body); + } + catch (Exception ex) + { + _logger.Error(ex, "Unable to send test email"); + return new ValidationFailure("Server", "Unable to send test email"); } + + return null; } private MailboxAddress ParseAddress(string type, string address) diff --git a/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs b/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs index ae495f42e..0c79c351a 100644 --- a/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs +++ b/src/NzbDrone.Core/Notifications/Email/EmailSettings.cs @@ -32,7 +32,8 @@ namespace NzbDrone.Core.Notifications.Email public EmailSettings() { - Port = 567; + Port = 587; + To = Array.Empty(); Cc = Array.Empty(); Bcc = Array.Empty(); diff --git a/src/NzbDrone.Core/Radarr.Core.csproj b/src/NzbDrone.Core/Radarr.Core.csproj index b44e73a51..992ba179a 100644 --- a/src/NzbDrone.Core/Radarr.Core.csproj +++ b/src/NzbDrone.Core/Radarr.Core.csproj @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/src/NzbDrone.Host/Radarr.Host.csproj b/src/NzbDrone.Host/Radarr.Host.csproj index 092650f8c..56c59881b 100644 --- a/src/NzbDrone.Host/Radarr.Host.csproj +++ b/src/NzbDrone.Host/Radarr.Host.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/NzbDrone.Update/Radarr.Update.csproj b/src/NzbDrone.Update/Radarr.Update.csproj index da0e1a393..035984116 100644 --- a/src/NzbDrone.Update/Radarr.Update.csproj +++ b/src/NzbDrone.Update/Radarr.Update.csproj @@ -4,8 +4,8 @@ net6.0 - - + +