Skip to content

Commit

Permalink
Improve Existing email template in Moderator & Subscriber (#182)
Browse files Browse the repository at this point in the history
* Update EmailTemplate.cs

Fix Typo

* Update SendSubscriberEmail.cs

Fix Typo

* Add Location in Moderator Email Template

Add location in Moderator Email Template

* Update Email Subject

Update email subject
  • Loading branch information
dyuvaraaj committed Sep 17, 2024
1 parent 6cb9573 commit d4329fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 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
2 changes: 1 addition & 1 deletion NotificationSystem/SendSubscriberEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static async Task<string> CreateBody(CloudQueue cloudQueue)
await cloudQueue.DeleteMessageAsync(message);
}

return EmailTemplate.GeSubscriberEmailBody(messagesJson);
return EmailTemplate.GetSubscriberEmailBody(messagesJson);
}
}
}
20 changes: 10 additions & 10 deletions NotificationSystem/Template/EmailTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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 GeSubscriberEmailBody(List<JObject> messages)
public static string GetSubscriberEmailBody(List<JObject> messages)
{
return $"<html><head><style>{GetCSS()}</style></head><body>{GetSubscriberEmailHtml(messages)}</body></html>";
}
Expand All @@ -26,7 +26,7 @@ private static string GetSubscriberEmailHtml(List<JObject> messages)
<body>
<div class='card'>
<h1>
Southern Resident Killer Whale Spotted
Southern Resident Killer Whale Detected
</h1>
<p>
Dear subscriber, a Southern Resident Killer Whale was most recently detected at around {timeString} PDT.
Expand All @@ -47,7 +47,7 @@ Please be mindful of their presence when travelling in the areas below.
</p>
</div>
<footer>
In partnership with Microsoft AI 4 Earth, Orca Sound and Orca Conservancy.
In partnership with Microsoft AI 4 Earth, Orcasound and Orca Conservancy.
</footer>
</body>
";
Expand Down Expand Up @@ -101,21 +101,21 @@ private static string GetMapUri(string locationName)
}
}

private static string GetModeratorEmailHtml(DateTime? timestamp)
private static string GetModeratorEmailHtml(DateTime? timestamp, string location)
{
string timeString = GetPDTTimestring(timestamp);

return $@"
<body>
<div class='card'>
<h1>
Orca Call Identified
Orca Call Candidate
</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.
This is a request for your moderation to confirm whether the sound was produced by Southern Resident Killer Whale on the portal below.
</p>
<hr/>
<h2>
Expand All @@ -131,7 +131,7 @@ Go to portal
<footer>
<br>
<center>
In partnership with Microsoft AI 4 Earth, Orca Sound and Orca Conservancy.
In partnership with Microsoft AI 4 Earth, Orcasound and Orca Conservancy.
</center>
</footer>
</body>
Expand Down

0 comments on commit d4329fa

Please sign in to comment.