Updated email settings

This commit is contained in:
2026-10-29 08:48:45 +02:00
parent 067af804ef
commit 1418914242
6 changed files with 21 additions and 29 deletions
@@ -34,8 +34,6 @@ public sealed class LateProjectEventHandler(IDbContextFactory<ApplicationDbConte
var now = DateTime.UtcNow;
var overdueCutoff = lateDays > 0 ? now.AddDays(-lateDays) : now;
// Query overdue milestones that are not yet approved
// Execute ToListAsync before GroupBy so EF Core does not fail SQL translation
var overdueMilestones = await context.Milestones
.AsNoTracking()
.Include(i => i.Project)
@@ -1,5 +1,3 @@
using System.Net;
using System.Text;
using PostFundManagement.Application.Abstractions.Services;
using PostFundManagement.Application.Services.Communications;
using PostFundManagement.Domain;
@@ -33,7 +31,6 @@ public sealed class NonCompliantProjectEventHandler(IDbContextFactory<Applicatio
var now = DateTime.UtcNow;
// Fetch active/monitored projects with programme, portfolio, and award organisations
var projects = await context.Projects
.AsNoTracking()
.Include(p => p.Programme)
@@ -167,14 +164,8 @@ public sealed class NonCompliantProjectEventHandler(IDbContextFactory<Applicatio
messageBody = messageBody.Replace("[ConsoleUrl]", "https://console.ifri.khongisa.co.za");
messageBody = messageBody.Replace("[Year]", now.Year.ToString());
var notificationRequest = new CreateNotificationRequest(
organisation.Id,
recipientId,
NotificationPlatform.Email,
$"[Audit Notice] Project Non-Compliance: {project.Name}",
recipientEmail,
messageBody,
NotificationStatus.Queued);
var notificationRequest = new CreateNotificationRequest(organisation.Id, recipientId, NotificationPlatform.Email,
$"[Audit Notice] Project Non-Compliance: {project.Name}", recipientEmail, messageBody, NotificationStatus.Queued);
_ = await service.CreateNotificationAsync(notificationRequest, SystemUser, cancellationToken);
@@ -206,14 +197,9 @@ public sealed class NonCompliantProjectEventHandler(IDbContextFactory<Applicatio
progMessageBody = progMessageBody.Replace("[PortalUrl]", "https://partner.ifri.khongisa.co.za");
progMessageBody = progMessageBody.Replace("[Year]", now.Year.ToString());
var progNotificationRequest = new CreateNotificationRequest(
organisation.Id,
programmeManagerId.Value,
NotificationPlatform.Email,
$"[Weekly Audit Escalation] Non-Compliant Project: {project.Name} ({programme?.Name})",
programmeManagerEmail,
progMessageBody,
NotificationStatus.Queued);
var progNotificationRequest = new CreateNotificationRequest(organisation.Id, programmeManagerId.Value, NotificationPlatform.Email,
$"[Weekly Audit Escalation] Non-Compliant Project: {project.Name} ({programme?.Name})",
programmeManagerEmail, progMessageBody, NotificationStatus.Queued);
_ = await service.CreateNotificationAsync(progNotificationRequest, SystemUser, cancellationToken);
}
@@ -1,5 +1,6 @@
using PostFundManagement.Application.Services.Shared;
using PostFundManagement.Domain.Abstractions;
using PostFundManagement.Domain.Configuration.Email;
using PostFundManagement.Infrastructure.Database;
namespace PostFundManagement.Application.Events;
@@ -18,9 +19,10 @@ public sealed class ProcessEmailEvent : IEvent
}
public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbContext> contextFactory,
IServiceProvider provider, IFeatureManager featureManager) : INotificationHandler<ProcessEmailEvent>
IServiceProvider provider, IFeatureManager featureManager, IOptions<SmtpSettings> options) : INotificationHandler<ProcessEmailEvent>
{
const int maxBatch = 100;
readonly SmtpSettings emailSettings = options.Value;
public async ValueTask Handle(ProcessEmailEvent notification, CancellationToken cancellationToken)
{
@@ -74,8 +76,8 @@ public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbCont
{
Sender = new Domain.Models.Email.Party
{
Address = "noreply@ifritechnologies.co.za",
Name = "Post Fund Management"
Address = emailSettings.SenderEmail,
Name = emailSettings.SenderName
},
Recipient = new Domain.Models.Email.Party
{