-
Notifications
You must be signed in to change notification settings - Fork 23
MMI-3382 Replace CHES #2553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Fosol
wants to merge
1
commit into
bcgov:dev
Choose a base branch
from
Fosol:mmi-3382
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MMI-3382 Replace CHES #2553
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| using System.Net.Mail; | ||
| using System.Security.Claims; | ||
| using System.Text; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.Extensions.Options; | ||
| using TNO.Ches; | ||
| using MMI.SmtpEmail; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced CHES with SMTP |
||
| using TNO.Core.Exceptions; | ||
| using TNO.Core.Extensions; | ||
| using TNO.DAL.Services; | ||
|
|
@@ -21,8 +22,7 @@ public class WatchSubscriptionChange | |
| private readonly IReportService _reportService; | ||
| private readonly IProductService _productService; | ||
| private readonly INotificationService _notificationService; | ||
| private readonly IChesService _chesService; | ||
| private readonly Ches.Configuration.ChesOptions _chesOptions; | ||
| private readonly IEmailService _emailService; | ||
|
|
||
| /// <summary> | ||
| /// SubscriptionChange enum, identifies the type of change. | ||
|
|
@@ -132,26 +132,23 @@ public class WatchOptions | |
| /// <param name="reportService"></param> | ||
| /// <param name="productService"></param> | ||
| /// <param name="notificationService"></param> | ||
| /// <param name="chesService"></param> | ||
| /// <param name="chesOptions"></param> | ||
| /// <param name="emailService"></param> | ||
| /// <param name="watchOptions"></param> | ||
| /// <param name="logger"></param> | ||
| public WatchSubscriptionChange( | ||
| IUserService userService, | ||
| IReportService reportService, | ||
| IProductService productService, | ||
| INotificationService notificationService, | ||
| IChesService chesService, | ||
| IOptions<Ches.Configuration.ChesOptions> chesOptions, | ||
| IEmailService emailService, | ||
| IOptions<WatchOptions> watchOptions, | ||
| ILogger<WatchSubscriptionChange> logger) | ||
| { | ||
| _userService = userService; | ||
| _reportService = reportService; | ||
| _productService = productService; | ||
| _notificationService = notificationService; | ||
| _chesService = chesService; | ||
| _chesOptions = chesOptions.Value; | ||
| _emailService = emailService; | ||
| this.Options = watchOptions.Value; | ||
| _logger = logger; | ||
| } | ||
|
|
@@ -165,7 +162,7 @@ public WatchSubscriptionChange( | |
| /// <param name="changeSource">The source of the change, generally the user who made the change.</param> | ||
| /// <param name="traceInformation">The location or other details to help trace the source of the change.</param> | ||
| /// <returns></returns> | ||
| public Ches.Models.EmailModel GenerateEmail(SubscriptionChange[] changes, string changeSource, string traceInformation) | ||
| public MailMessage GenerateEmail(SubscriptionChange[] changes, string changeSource, string traceInformation) | ||
| { | ||
| var body = new StringBuilder($""" | ||
| <div>This is an alert to identify changes to user subscriptions.</div> | ||
|
|
@@ -234,7 +231,7 @@ public Ches.Models.EmailModel GenerateEmail(SubscriptionChange[] changes, string | |
| } | ||
|
|
||
| var to = this.Options.SendTo.Split(','); | ||
| return new Ches.Models.EmailModel(_chesOptions.From, to, "MMI - User Subscription Change Alert", body.ToString()); | ||
| return _emailService.CreateMailMessage("MMI - User Subscription Change Alert", body.ToString(), to, null, null, null, isHtml: true); | ||
| } | ||
|
|
||
| #region Users | ||
|
|
@@ -285,7 +282,7 @@ public async Task AlertUserSubscriptionChangedAsync(Entities.User user, string c | |
| if (changes.Length > 0) | ||
| { | ||
| var email = GenerateEmail(changes, changeSource, traceInformation); | ||
| await _chesService.SendEmailAsync(email); | ||
| await _emailService.SendAsync(email); | ||
| } | ||
| } | ||
| #endregion | ||
|
|
@@ -335,7 +332,7 @@ public async Task AlertProductSubscriptionChangedAsync(Entities.Product product, | |
| if (changes.Length > 0) | ||
| { | ||
| var email = GenerateEmail(changes, changeSource, traceInformation); | ||
| await _chesService.SendEmailAsync(email); | ||
| await _emailService.SendAsync(email); | ||
| } | ||
| } | ||
| #endregion | ||
|
|
@@ -385,7 +382,7 @@ public async Task AlertReportSubscriptionChangedAsync(Entities.Report report, st | |
| if (changes.Length > 0) | ||
| { | ||
| var email = GenerateEmail(changes, changeSource, traceInformation); | ||
| await _chesService.SendEmailAsync(email); | ||
| await _emailService.SendAsync(email); | ||
| } | ||
| } | ||
| #endregion | ||
|
|
@@ -435,7 +432,7 @@ public async Task AlertNotificationSubscriptionChangedAsync(Entities.Notificatio | |
| if (changes.Length > 0) | ||
| { | ||
| var email = GenerateEmail(changes, changeSource, traceInformation); | ||
| await _chesService.SendEmailAsync(email); | ||
| await _emailService.SendAsync(email); | ||
| } | ||
| } | ||
| #endregion | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,23 @@ public IActionResult Update([FromBody] AVOverviewInstanceModel model) | |
| return new JsonResult(new AVOverviewInstanceModel(instance, _serializerOptions)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get all user report instances for the specified instance 'id'. | ||
| /// </summary> | ||
| /// <param name="id"></param> | ||
| /// <param name="userId"></param> | ||
| /// <returns></returns> | ||
| [HttpGet("{id}/users/{userId}")] | ||
| [Produces(MediaTypeNames.Application.Json)] | ||
| [ProducesResponseType(typeof(UserAVOverviewInstanceModel), (int)HttpStatusCode.OK)] | ||
| [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] | ||
| [SwaggerOperation(Tags = new[] { "Evening Overview" })] | ||
| public IActionResult GetUserAVOverviewInstanceAsync(long id, int userId) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New endpoint so that our SMTP Retry Service can update each record. |
||
| { | ||
| var result = _overviewInstanceService.GetUserAVOverviewInstance(id, userId) ?? throw new NoContentException(); | ||
| return new JsonResult(new UserAVOverviewInstanceModel(result)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get all user report instances for the specified instance 'id'. | ||
| /// </summary> | ||
|
|
@@ -103,8 +120,8 @@ public IActionResult Update([FromBody] AVOverviewInstanceModel model) | |
| [SwaggerOperation(Tags = new[] { "Evening Overview" })] | ||
| public IActionResult GetUserAVOverviewInstancesAsync(long id) | ||
| { | ||
| var content = _overviewInstanceService.GetUserAVOverviewInstances(id); | ||
| return new JsonResult(content.Select(c => new UserAVOverviewInstanceModel(c))); | ||
| var result = _overviewInstanceService.GetUserAVOverviewInstances(id); | ||
| return new JsonResult(result.Select(c => new UserAVOverviewInstanceModel(c))); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced CHES with SMTP