From b768b051d7333bb52fdc5708262fb6ab8fca87bc Mon Sep 17 00:00:00 2001 From: dyuvaraaj Date: Tue, 17 Sep 2024 14:07:02 -0700 Subject: [PATCH] Add Location in Moderator Email Template Add location in Moderator Email Template --- NotificationSystem/SendModeratorEmail.cs | 7 +++++-- NotificationSystem/Template/EmailTemplate.cs | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/NotificationSystem/SendModeratorEmail.cs b/NotificationSystem/SendModeratorEmail.cs index 986304fe..d58cdee6 100644 --- a/NotificationSystem/SendModeratorEmail.cs +++ b/NotificationSystem/SendModeratorEmail.cs @@ -35,6 +35,7 @@ public static async Task Run( var newDocumentCreated = false; DateTime? documentTimeStamp = null; + string location = null; foreach (var document in input) { @@ -42,6 +43,7 @@ public static async Task Run( { newDocumentCreated = true; documentTimeStamp = document.GetPropertyValue("timestamp"); + location = document.GetPropertyValue("location.name"); break; } } @@ -53,13 +55,14 @@ public static async Task Run( } // TODO: make better email - string body = EmailTemplate.GetModeratorEmailBody(documentTimeStamp); + string body = EmailTemplate.GetModeratorEmailBody(documentTimeStamp, location); log.LogInformation("Retrieving email list and sending notifications"); foreach (var emailEntity in EmailHelpers.GetEmailEntities(cloudTable, "Moderator")) { + string emailSubject = string.Format("OrcaHello Candidate at location {0}", location); var email = EmailHelpers.CreateEmail(Environment.GetEnvironmentVariable("SenderEmail"), - emailEntity.Email, "Please validate new OrcaHello detection", body); + emailEntity.Email, emailSubject, body); await messageCollector.AddAsync(email); } } diff --git a/NotificationSystem/Template/EmailTemplate.cs b/NotificationSystem/Template/EmailTemplate.cs index 6238c054..3029e07f 100644 --- a/NotificationSystem/Template/EmailTemplate.cs +++ b/NotificationSystem/Template/EmailTemplate.cs @@ -8,9 +8,9 @@ namespace NotificationSystem.Template // TODO: we should move all html out of code and maybe use a preset email template for better design. public static class EmailTemplate { - public static string GetModeratorEmailBody(DateTime? timestamp) + public static string GetModeratorEmailBody(DateTime? timestamp, string location) { - return $"{GetModeratorEmailHtml(timestamp)}"; + return $"{GetModeratorEmailHtml(timestamp, location)}"; } public static string GetSubscriberEmailBody(List messages) @@ -101,7 +101,7 @@ private static string GetMapUri(string locationName) } } - private static string GetModeratorEmailHtml(DateTime? timestamp) + private static string GetModeratorEmailHtml(DateTime? timestamp, string location) { string timeString = GetPDTTimestring(timestamp); @@ -112,7 +112,7 @@ private static string GetModeratorEmailHtml(DateTime? timestamp) Orca Call Identified

- Dear moderator, a potential Southern Resident Killer Whale call was detected on {timeString} PDT. + Dear moderator, a potential Southern Resident Killer Whale call was detected on {timeString} PDT at {location} location.

This is a request for your moderation to confirm whether the sound belongs to a Southern Resident Killer Whale on the portal below.