Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,18 @@
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Run Ches Retry Service",
"name": "Run SMTP Retry Service",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced CHES with SMTP

"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-ches-retry",
"preLaunchTask": "build-smtp-retry",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/services/net/ches-retry/bin/Debug/net9.0/TNO.Services.ChesRetry.dll",
"program": "${workspaceFolder}/services/net/smtp-retry/bin/Debug/net9.0/MMI.Services.SMTPRetry.dll",
"args": [],
"cwd": "${workspaceFolder}/services/net/ches-retry",
"cwd": "${workspaceFolder}/services/net/smtp-retry",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false,
"envFile": "${workspaceFolder}/services/net/ches-retry/.env"
"envFile": "${workspaceFolder}/services/net/smtp-retry/.env"
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
Expand Down
12 changes: 6 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,38 +645,38 @@
"problemMatcher": "$msCompile"
},
{
"label": "build-ches-retry",
"label": "build-smtp-retry",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj",
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish-ches-retry",
"label": "publish-smtp-retry",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj",
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch-ches-retry",
"label": "watch-smtp-retry",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj"
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj"
],
"problemMatcher": "$msCompile"
},
Expand Down
28 changes: 21 additions & 7 deletions TNO.sln
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.FFmpeg", "serv
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.EventHandler", "services\net\event-handler\TNO.Services.EventHandler.csproj", "{6F1F9B85-B155-4A5A-BB36-10F734F96A12}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.ChesRetry", "services\net\ches-retry\TNO.Services.ChesRetry.csproj", "{067EA7C3-A816-406B-B36A-09FC05A427A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.AutoClipper", "services\net\auto-clipper\TNO.Services.AutoClipper.csproj", "{7B8BF924-36BA-422E-85FD-1C590B092F7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMI.SmtpEmail", "libs\net\smtp\MMI.SmtpEmail.csproj", "{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.NLP", "services\net\nlp\TNO.Services.NLP.csproj", "{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMI.Services.SmtpRetry", "services\net\smtp-retry\MMI.Services.SmtpRetry.csproj", "{66BC5554-D360-450A-A529-97EAB4D56637}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -218,14 +222,22 @@ Global
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Release|Any CPU.Build.0 = Release|Any CPU
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.Build.0 = Release|Any CPU
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.Build.0 = Release|Any CPU
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Release|Any CPU.Build.0 = Release|Any CPU
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Release|Any CPU.Build.0 = Release|Any CPU
{66BC5554-D360-450A-A529-97EAB4D56637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66BC5554-D360-450A-A529-97EAB4D56637}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66BC5554-D360-450A-A529-97EAB4D56637}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66BC5554-D360-450A-A529-97EAB4D56637}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{16EA028B-B4C8-416D-BE54-D73D75483668} = {F627B24A-217D-4BF1-BC77-E1A92DBCD07F}
Expand Down Expand Up @@ -263,7 +275,9 @@ Global
{E7444ADF-0137-439B-8E20-917CF2FAFA45} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{2D455400-0E86-476E-8C42-532D32C10107} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{6F1F9B85-B155-4A5A-BB36-10F734F96A12} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{067EA7C3-A816-406B-B36A-09FC05A427A1} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{7B8BF924-36BA-422E-85FD-1C590B092F7B} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C} = {890D13F9-A1ED-4B00-8E69-A1AB620F31A9}
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
{66BC5554-D360-450A-A529-97EAB4D56637} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public IActionResult FindById(long id)
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
public IActionResult Add([FromBody] NotificationInstanceModel model)
{
var result = _service.AddAndSave(model.ToEntity(_serializerOptions));
var result = _service.AddAndSave((Entities.NotificationInstance)model);
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result, _serializerOptions));
}

Expand All @@ -96,7 +96,7 @@ public IActionResult Add([FromBody] NotificationInstanceModel model)
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
public async Task<IActionResult> UpdateAsync([FromBody] NotificationInstanceModel model)
{
var notificationInstance = model.ToEntity(_serializerOptions);
var notificationInstance = (Entities.NotificationInstance)model;
// TODO: This shouldn't occur, but if it does we want to know.
if (notificationInstance.Notification != null)
await _watch.AlertNotificationSubscriptionChangedAsync(notificationInstance.Notification, this.User, "API Admin Notification Instance Controller Update endpoint.");
Expand All @@ -116,7 +116,7 @@ public async Task<IActionResult> UpdateAsync([FromBody] NotificationInstanceMode
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
public IActionResult Delete([FromBody] NotificationInstanceModel model)
{
_service.DeleteAndSave(model.ToEntity(_serializerOptions));
_service.DeleteAndSave((Entities.NotificationInstance)model);
return new JsonResult(model);
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion api/net/Areas/Editor/Controllers/ContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public async Task<IActionResult> AttachFileAsync([FromRoute] long contentId, [Fr
public IActionResult GetNotificationsFor(long id)
{
var notifications = _contentService.GetNotificationsFor(id);
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n, _serializerOptions)));
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n)));
}
#endregion
#endregion
Expand Down
27 changes: 12 additions & 15 deletions api/net/Areas/Helpers/WatchSubscriptionChange.cs
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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;
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions api/net/Areas/Services/Controllers/AVOverviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion api/net/Areas/Services/Controllers/ContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public async Task<IActionResult> GetImageFile(long id)
public IActionResult GetNotificationsFor(long id)
{
var notifications = _contentService.GetNotificationsFor(id);
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n, _serializerOptions)));
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n)));
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions api/net/Areas/Services/Controllers/NotificationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public async Task<IActionResult> FindContentForNotificationIdAsync(int id, int?
/// <returns></returns>
[HttpGet("sent/{status}")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<ChesNotificationMessagesModel>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<SmtpNotificationMessagesModel>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[SwaggerOperation(Tags = new[] { "Notification" })]
public IActionResult GetChesMessages(Entities.NotificationStatus status, [FromQuery] DateTime cutOff)
public IActionResult GetSmtpMessages(Entities.NotificationStatus status, [FromQuery] DateTime cutOff)
{
var messages = _service.GetChesMessageIds(status, cutOff);
var messages = _service.GetSmtpMessages(status, cutOff);
return new JsonResult(messages);
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IActionResult FindById(long id)
{
var result = _service.FindById(id);
if (result == null) return NoContent();
return new JsonResult(new NotificationInstanceModel(result, _serializerOptions));
return new JsonResult(new NotificationInstanceModel(result));
}

/// <summary>
Expand All @@ -76,8 +76,8 @@ public IActionResult FindById(long id)
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
public IActionResult Add([FromBody] NotificationInstanceModel model)
{
var result = _service.AddAndSave(model.ToEntity(_serializerOptions));
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result, _serializerOptions));
var result = _service.AddAndSave((Entities.NotificationInstance)model);
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result));
}

/// <summary>
Expand All @@ -97,7 +97,7 @@ public IActionResult UpdateNotificationInstanceStatus(long id, Entities.Notifica
instance.Status = status;
_service.UpdateAndSave(instance);

return new JsonResult(new NotificationInstanceModel(instance, _serializerOptions));
return new JsonResult(new NotificationInstanceModel(instance));
}
#endregion
}
6 changes: 3 additions & 3 deletions api/net/Areas/Services/Controllers/ReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ public IActionResult ClearFoldersInReportId(int id)
/// <returns></returns>
[HttpGet("sent/{status}")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<Models.Report.ChesReportMessagesModel>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<Models.Report.SmtpReportMessagesModel>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[SwaggerOperation(Tags = new[] { "Report" })]
public IActionResult GetChesMessages(Entities.ReportStatus status, [FromQuery] DateTime cutOff)
public IActionResult GetSmtpMessages(Entities.ReportStatus status, [FromQuery] DateTime cutOff)
{
var messages = _service.GetChesMessageIds(status, cutOff);
var messages = _service.GetSmtpMessageIds(status, cutOff);
return new JsonResult(messages);
}
#endregion
Expand Down
Loading
Loading