Skip to content

Commit

Permalink
MMI-3100 image tag email alert, migration 1.3.19 (#2404)
Browse files Browse the repository at this point in the history
* MMI-3100 changes to Notification template to add image

* MMI-3100 changes to basic notification template to include file reference when available.

* MMI-3100 changes to DefaultRazorTemplate in Editor

* MMI-3100 change to Where clause in Notification template

* Updated defaultRazorTemplate sentiment

---------

Co-authored-by: Dao Yu Lai <daoyu.lai@gov.bc.ca>
  • Loading branch information
nehalaggarwal-bcgov and laidaoyu authored Feb 13, 2025
1 parent 9816cbc commit 17bcf68
Show file tree
Hide file tree
Showing 4 changed files with 7,610 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ export const defaultRazorTemplate = {
var body = isTranscriptAvailable ? @Content.Body : (isAV ? @Content.Summary : @Content.Body);
var transcriptIcon = isTranscriptAvailable ? "▶️📄" : (isAV ? "▶️" : "");
var toneIcon = "";
switch (@Content.TonePools.FirstOrDefault()?.Value)
if (@EnableReportSentiment)
{
case 0:
toneIcon = "😐 ";
break;
case -3:
case -4:
case -5:
toneIcon = "☹️ ";
break;
case 3:
case 4:
case 5:
toneIcon = "🙂 ";
break;
switch (@Content.TonePools.FirstOrDefault()?.Value)
{
case 0:
toneIcon = "😐 ";
break;
case -3:
case -4:
case -5:
toneIcon = "☹️ ";
break;
case 3:
case 4:
case 5:
toneIcon = "🙂 ";
break;
}
}
}DEV | @toneIcon@sourceCode: @Content.Headline @transcriptIcon`,
body: `@inherits RazorEngineCore.RazorEngineTemplateBase<TNO.TemplateEngine.Models.Notifications.NotificationEngineContentModel>
Expand All @@ -49,6 +52,11 @@ export const defaultRazorTemplate = {
<div>@Content.Series.Name</div>
}
<div>@Content.PublishedOn?.AddHours(@utcOffset).ToString("dd-MMM-yyyy hh:mm")</div>
@if (!string.IsNullOrEmpty(@Content.ImageContent))
{
var src = $"data:{@Content.ContentType};base64," + Content.ImageContent;
<div><img src="@src" alt="@Content.FileReferences.FirstOrDefault()?.FileName" /></div>
}
<div>@body</div>
<br />
@if (!string.IsNullOrEmpty(subscriberAppUrl))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
DO $$
BEGIN

-- Update the basic alert template.
UPDATE public."notification_template" SET
"body" = '@inherits RazorEngineCore.RazorEngineTemplateBase<TNO.TemplateEngine.Models.Notifications.NotificationEngineContentModel>
@using System
@using System.Web
@{
var subscriberAppUrl = @SubscriberAppUrl?.ToString();
var viewContentUrl = @ViewContentUrl?.ToString();
var requestTranscriptUrl = @RequestTranscriptUrl?.ToString();
var addToReportUrl = @AddToReportUrl?.ToString();
var isAV = @Content.ContentType == TNO.Entities.ContentType.AudioVideo;
var isTranscriptAvailable = isAV && !string.IsNullOrWhiteSpace(@Content.Body) && @Content.IsApproved;
var sourceCode = !string.IsNullOrEmpty(@Content.Source?.Code) ? @Content.Source.Code : @Content.OtherSource;
var body = isTranscriptAvailable ? @Content.Body : (isAV ? @Content.Summary : @Content.Body);
// body = System.Text.RegularExpressions.Regex.Replace(body, @"\r\n?|\n", "<br/>");
var replaceWith = "<br/>";
body = body.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith);
var tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var utcOffset = tz.GetUtcOffset(System.DateTime.Now).Hours;
}
@if (!string.IsNullOrWhiteSpace(@Content.Source?.Name))
{
<div>@Content.Source.Name</div>
}
@if (!string.IsNullOrEmpty(@Content.Series?.Name))
{
<div>@Content.Series.Name</div>
}
<div>@Content.PublishedOn?.AddHours(@utcOffset).ToString("dd-MMM-yyyy HH:mm")</div>
@if (!string.IsNullOrEmpty(@Content.Byline))
{
<div>@Content.Byline</div>
}
@if (!string.IsNullOrEmpty(@Content.Page))
{
<div>Page #@Content.Page</div>
}
@if (!string.IsNullOrEmpty(@Content.ImageContent))
{
var src = $"data:{@Content.ContentType};base64," + Content.ImageContent;
<div><img src="@src" alt="@Content.FileReferences.FirstOrDefault()?.FileName" /></div>
}
<br/>
<div>@body</div>
<br />
@if (!string.IsNullOrEmpty(subscriberAppUrl))
{
<div><a href="@subscriberAppUrl" target="">MMI</a> :: <a href="@viewContentUrl@Content.Id" target="_blank">View Article</a></div>
<br />
}
@if (isAV && !isTranscriptAvailable && !string.IsNullOrEmpty(requestTranscriptUrl) && Content.Source?.DisableTranscribe == false)
{
<div><a href="@($"{requestTranscriptUrl}{Content.Id}")?uid=@(Content.OwnerId)&headline=@(HttpUtility.UrlEncode(Content.Headline))&source=@(HttpUtility.UrlEncode(Content.OtherSource))" target="_blank">Request Transcript...</a></div>
<br />
}
<br />
<div style="font-size: 10px;">
This e-mail is a service provided by Government Communications and Public Engagement and is only intended
for the original addressee. All content is the copyrighted property of a third party creator of the material.
Copying, retransmitting, redistributing, selling, licensing, or emailing the material to any third party or
any employee of the Province who is not authorized to access the material is prohibited.
</div>'
WHERE "id" = cast((SELECT value FROM setting
WHERE name = 'BasicAlertTemplateId') as integer);

END $$;
Loading

0 comments on commit 17bcf68

Please sign in to comment.