Skip to content

Commit

Permalink
Add Location in Moderator Email Template
Browse files Browse the repository at this point in the history
Add location in Moderator Email Template
  • Loading branch information
dyuvaraaj committed Sep 17, 2024
1 parent ee073ab commit b768b05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions NotificationSystem/SendModeratorEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ public static async Task Run(

var newDocumentCreated = false;
DateTime? documentTimeStamp = null;
string location = null;

foreach (var document in input)
{
if (!document.GetPropertyValue<bool>("reviewed"))
{
newDocumentCreated = true;
documentTimeStamp = document.GetPropertyValue<DateTime>("timestamp");
location = document.GetPropertyValue<string>("location.name");
break;
}
}
Expand All @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions NotificationSystem/Template/EmailTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $"<html><head><style>{GetCSS()}</style></head><body>{GetModeratorEmailHtml(timestamp)}</body></html>";
return $"<html><head><style>{GetCSS()}</style></head><body>{GetModeratorEmailHtml(timestamp, location)}</body></html>";
}

public static string GetSubscriberEmailBody(List<JObject> messages)
Expand Down Expand Up @@ -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);

Expand All @@ -112,7 +112,7 @@ private static string GetModeratorEmailHtml(DateTime? timestamp)
Orca Call Identified
</h1>
<p>
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.
</p>
<p>
This is a request for your moderation to confirm whether the sound belongs to a Southern Resident Killer Whale on the portal below.
Expand Down

0 comments on commit b768b05

Please sign in to comment.