Skip to content

Commit

Permalink
Merge branch 'orcasound:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bnestor authored Sep 18, 2024
2 parents 310fbc5 + 736c864 commit b933d99
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/OrcaHello.Web.Api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: OrcaHello.Web.Api

on:
pull_request:
branches:
- main
paths:
- ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api/**
- ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Shared/**
push:
branches:
- main
Expand All @@ -10,7 +16,7 @@ on:
workflow_dispatch: # Allow manual workflow invocation from the Github Actions UI

env:
DOTNET_VERSION: 6.0.x
DOTNET_VERSION: 8.0.x
DOTNET_RUNTIME: win-x86
WORKING_DIR: ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Api
PUBLISH_DIR: output
Expand All @@ -31,7 +37,7 @@ jobs:
egress-policy: audit
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/OrcaHello.Web.UI.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: OrcaHello.Web.UI

on:
pull_request:
branches:
- main
paths:
- ModeratorFrontEnd/OrcaHello/OrcaHello.Web.UI/**
- ModeratorFrontEnd/OrcaHello/OrcaHello.Web.Shared/**
push:
branches:
- main
Expand All @@ -10,7 +16,7 @@ on:
workflow_dispatch: # Allow manual workflow invocation from the Github Actions UI

env:
DOTNET_VERSION: 6.0.x
DOTNET_VERSION: 8.0.x
DOTNET_RUNTIME: win-x86
WORKING_DIR: ModeratorFrontEnd/OrcaHello/OrcaHello.Web.UI
PUBLISH_DIR: output
Expand All @@ -31,7 +37,7 @@ jobs:
egress-policy: audit
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Blazorade.Msal" Version="2.2.0" />
<PackageReference Include="Radzen.Blazor" Version="4.20.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
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 b933d99

Please sign in to comment.