Skip to content

Commit

Permalink
allow removal of notification config section
Browse files Browse the repository at this point in the history
  • Loading branch information
toutas committed Nov 20, 2021
1 parent 8b06ad4 commit c22bbc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Models/NotificationConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace SARotate.Models
public class NotificationConfig
{
[YamlDotNet.Serialization.YamlMember(Alias = "errors_only")]
public bool AppriseNotificationsErrorsOnly { get; set; }
public bool AppriseNotificationsErrorsOnly { get; set; } = true;
[YamlDotNet.Serialization.YamlMember(Alias = "apprise")]
public List<string> AppriseServices { get; set; }
public List<string> AppriseServices { get; set; } = new List<string>();
}
}
2 changes: 1 addition & 1 deletion Models/SARotateConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SARotateConfig
/// <summary>
/// svcAcctGroup absolute path -> remote -> connection info
/// </summary>
[YamlMember(Alias = "notification")] public NotificationConfig NotificationConfig { get; set; }
[YamlMember(Alias = "notification")] public NotificationConfig NotificationConfig { get; set; } = new NotificationConfig();

// ReSharper disable once InconsistentNaming
public static SARotateConfig? ParseSARotateYamlConfig(string configAbsolutePath)
Expand Down
2 changes: 1 addition & 1 deletion SARotate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private async Task LogRCloneServiceAccountSwapResult(

private async Task SendAppriseNotification(SARotateConfig yamlConfigContent, string logMessage, LogLevel logLevel = LogLevel.Debug)
{
if (yamlConfigContent.NotificationConfig.AppriseNotificationsErrorsOnly && logLevel < LogLevel.Error)
if (yamlConfigContent.NotificationConfig.AppriseNotificationsErrorsOnly && yamlConfigContent.NotificationConfig.AppriseServices.Any() && logLevel < LogLevel.Error)
{
LogMessage($"apprise notification not sent due to errors_only notifications: {logMessage}", logLevel);
}
Expand Down

0 comments on commit c22bbc4

Please sign in to comment.