Skip to content
Snippets Groups Projects
Commit 331dcad8 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Change SendAdminEmail to return a bool

parent 3af8ad75
No related branches found
No related tags found
No related merge requests found
...@@ -78,16 +78,17 @@ namespace ATxService ...@@ -78,16 +78,17 @@ namespace ATxService
/// </summary> /// </summary>
/// <param name="body">The email text.</param> /// <param name="body">The email text.</param>
/// <param name="subject">Optional subject for the email.</param> /// <param name="subject">Optional subject for the email.</param>
private void SendAdminEmail(string body, string subject = "") { /// <returns>True in case an email was sent, false otherwise.</returns>
private bool SendAdminEmail(string body, string subject = "") {
if (_config.SendAdminNotification == false) if (_config.SendAdminNotification == false)
return; return false;
var delta = TimeUtils.MinutesSince(_status.LastAdminNotification); var delta = TimeUtils.MinutesSince(_status.LastAdminNotification);
if (delta < _config.AdminNotificationDelta) { if (delta < _config.AdminNotificationDelta) {
Log.Warn("Suppressed admin email, interval too short ({0} vs. {1}):\n\n{2}\n{3}", Log.Warn("Suppressed admin email, interval too short ({0} vs. {1}):\n\n{2}\n{3}",
TimeUtils.MinutesToHuman(delta), TimeUtils.MinutesToHuman(delta),
TimeUtils.MinutesToHuman(_config.AdminNotificationDelta), subject, body); TimeUtils.MinutesToHuman(_config.AdminNotificationDelta), subject, body);
return; return false;
} }
if (string.IsNullOrWhiteSpace(subject)) if (string.IsNullOrWhiteSpace(subject))
...@@ -97,7 +98,8 @@ namespace ATxService ...@@ -97,7 +98,8 @@ namespace ATxService
Log.Debug("Sending an admin notification email."); Log.Debug("Sending an admin notification email.");
SendEmail(_config.AdminEmailAdress, subject, body); SendEmail(_config.AdminEmailAdress, subject, body);
_status.LastAdminNotification = DateTime.Now; _status.LastAdminNotification = DateTime.Now;
Log.Debug("{0} sent to AdminEmailAdress.", subject);
return true;
} }
/// <summary> /// <summary>
...@@ -229,9 +231,7 @@ namespace ATxService ...@@ -229,9 +231,7 @@ namespace ATxService
} }
_status.LastGraceNotification = DateTime.Now; _status.LastGraceNotification = DateTime.Now;
SendAdminEmail(report, "grace location summary"); return SendAdminEmail(report, "grace location summary");
Log.Debug("Notification sent to AdminEmailAdress.");
return true;
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment