|
| 1 | +DO $$ |
| 2 | +BEGIN |
| 3 | + |
| 4 | +-- Update the basic alert template. |
| 5 | +UPDATE public."notification_template" SET |
| 6 | + "subject" = '@inherits RazorEngineCore.RazorEngineTemplateBase<TNO.TemplateEngine.Models.Notifications.NotificationEngineContentModel> |
| 7 | +@using System.Linq |
| 8 | +@{ |
| 9 | + var isAV = @Content.ContentType == TNO.Entities.ContentType.AudioVideo; |
| 10 | + var useSummary = @Content.ContentType == TNO.Entities.ContentType.Image || isAV; |
| 11 | + var isTranscriptAvailable = isAV && !string.IsNullOrWhiteSpace(@Content.Body) && @Content.IsApproved; |
| 12 | + var sourceCode = !string.IsNullOrEmpty(@Content.Source?.Code) ? @Content.Source.Code : @Content.OtherSource; |
| 13 | + var body = isTranscriptAvailable ? @Content.Body : (useSummary ? @Content.Summary : @Content.Body); |
| 14 | + var transcriptIcon = isTranscriptAvailable ? "▶️📄" : (isAV ? "▶️" : ""); |
| 15 | + var toneIcon = ""; |
| 16 | + if (@EnableReportSentiment) |
| 17 | + { |
| 18 | + switch (@Content.TonePools.FirstOrDefault()?.Value) |
| 19 | + { |
| 20 | + case 0: |
| 21 | + toneIcon = "😐 "; |
| 22 | + break; |
| 23 | + case -3: |
| 24 | + case -4: |
| 25 | + case -5: |
| 26 | + toneIcon = "☹️ "; |
| 27 | + break; |
| 28 | + case 3: |
| 29 | + case 4: |
| 30 | + case 5: |
| 31 | + toneIcon = "🙂 "; |
| 32 | + break; |
| 33 | + } |
| 34 | + } |
| 35 | +}@toneIcon@sourceCode: @Content.Headline @transcriptIcon' |
| 36 | + , "body" = '@inherits RazorEngineCore.RazorEngineTemplateBase<TNO.TemplateEngine.Models.Notifications.NotificationEngineContentModel> |
| 37 | +@using System |
| 38 | +@using System.Web |
| 39 | +@using System.Linq |
| 40 | +@{ |
| 41 | + var subscriberAppUrl = @SubscriberAppUrl?.ToString(); |
| 42 | + var viewContentUrl = @ViewContentUrl?.ToString(); |
| 43 | + var requestTranscriptUrl = @RequestTranscriptUrl?.ToString(); |
| 44 | + var addToReportUrl = @AddToReportUrl?.ToString(); |
| 45 | + var isAV = @Content.ContentType == TNO.Entities.ContentType.AudioVideo; |
| 46 | + var useSummary = @Content.ContentType == TNO.Entities.ContentType.Image || isAV; |
| 47 | + var isTranscriptAvailable = isAV && !string.IsNullOrWhiteSpace(@Content.Body) && @Content.IsApproved; |
| 48 | + var sourceCode = !string.IsNullOrEmpty(@Content.Source?.Code) ? @Content.Source.Code : @Content.OtherSource; |
| 49 | + var body = isTranscriptAvailable ? @Content.Body : (useSummary ? @Content.Summary : @Content.Body); |
| 50 | + var replaceWith = "<br/>"; |
| 51 | + body = body.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith); |
| 52 | + var filePath = @Content.FileReferences.FirstOrDefault()?.Path; |
| 53 | +
|
| 54 | + var tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); |
| 55 | + var utcOffset = tz.GetUtcOffset(System.DateTime.Now).Hours; |
| 56 | +} |
| 57 | +@if (!string.IsNullOrWhiteSpace(@Content.Source?.Name)) |
| 58 | +{ |
| 59 | + <div>@Content.Source.Name</div> |
| 60 | +} |
| 61 | +@if (!string.IsNullOrEmpty(@Content.Series?.Name)) |
| 62 | +{ |
| 63 | + <div>@Content.Series.Name</div> |
| 64 | +} |
| 65 | +<div>@Content.PublishedOn?.AddHours(@utcOffset).ToString("dd-MMM-yyyy HH:mm")</div> |
| 66 | +@if (!string.IsNullOrEmpty(@Content.Byline)) |
| 67 | +{ |
| 68 | + <div>@Content.Byline</div> |
| 69 | +} |
| 70 | +@if (!string.IsNullOrEmpty(@Content.Page)) |
| 71 | +{ |
| 72 | + <div>Page #@Content.Page</div> |
| 73 | +} |
| 74 | +@if (@Content.ContentType == TNO.Entities.ContentType.Image && !string.IsNullOrEmpty(filePath)) |
| 75 | +{ |
| 76 | + var apiFileUrl = subscriberAppUrl + "api/subscriber/contents/download?path=" + filePath; |
| 77 | + <div><img src="@apiFileUrl" alt="@Content.FileReferences.FirstOrDefault()?.FileName" /></div> |
| 78 | +} |
| 79 | +<br/> |
| 80 | +<p> |
| 81 | +<hr></hr> |
| 82 | +<div>@body</div> |
| 83 | +<br /> |
| 84 | +@if (!string.IsNullOrEmpty(subscriberAppUrl)) |
| 85 | +{ |
| 86 | + <div><a href="@subscriberAppUrl" target="">MMI</a> : <a href="@viewContentUrl@Content.Id" target="_blank">View article on MMI website</a></div> |
| 87 | + <br /> |
| 88 | +} |
| 89 | +@if (isAV && !isTranscriptAvailable && !string.IsNullOrEmpty(requestTranscriptUrl) && Content.Source?.DisableTranscribe == false) |
| 90 | +{ |
| 91 | + <div><a href="@($"{requestTranscriptUrl}{Content.Id}")?uid=@(Content.OwnerId)&headline=@(HttpUtility.UrlEncode(Content.Headline))&source=@(HttpUtility.UrlEncode(Content.OtherSource))" target="_blank" |
| 92 | + style="margin-left:auto; padding:0.5em; color:#123456; background-color:#fff7e1; border:2px solid #dcc797; height:2em; border-radius:0.85em; text-decoration:none; display:inline-flex; align-items:center; gap:0.5em;" |
| 93 | + onmouseover="this.style.backgroundColor=''#ffebb3'';" |
| 94 | + onmouseout="this.style.backgroundColor=''#fff7e1'';"> |
| 95 | + <i class="fa fa-feather" style="color:#cccccc;"></i> Request Transcript</a> |
| 96 | + </div> |
| 97 | + <br /> |
| 98 | +} |
| 99 | +<br /><hr></hr> |
| 100 | +<div style="font-size: 14px;"> |
| 101 | +<b>This e-mail is a service provided by Government Communications and Public Engagement and is only intended |
| 102 | + for the original addressee. All content is the copyrighted property of a third party creator of the material. Copying, re-transmitting, redistributing, selling, licensing, or e-mailing the material to any third party or any employee of the Province who is not authorized to access the material is prohibited. </b> |
| 103 | +</div>' |
| 104 | +WHERE "id" = cast((SELECT value FROM setting |
| 105 | + WHERE name = 'BasicAlertTemplateId') as integer); |
| 106 | + |
| 107 | +END $$; |
0 commit comments