Updated email settings
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -7,6 +7,10 @@ public sealed class SmtpSettings
|
||||
public int Port { get; set; }
|
||||
|
||||
public string? Host { get; set; }
|
||||
|
||||
public string? SenderEmail { get; set; }
|
||||
|
||||
public string? SenderName { get; set; }
|
||||
|
||||
public bool UseSsl { get; set; }
|
||||
}
|
||||
@@ -29,10 +29,10 @@
|
||||
}
|
||||
},
|
||||
"Email": {
|
||||
"SmtpServer": "smtp.example.com",
|
||||
"SmtpPort": 587,
|
||||
"SenderEmail": "noreply@example.com",
|
||||
"SenderName": "Example"
|
||||
"SmtpServer": "mail.litecharms.co.za",
|
||||
"SmtpPort": 465,
|
||||
"SenderEmail": "pfm@litecharms.co.za",
|
||||
"SenderName": "Post Fund Management Updates"
|
||||
},
|
||||
"HasherSettings": {
|
||||
"MinHashLength": 11
|
||||
|
||||
+3
-1
@@ -51,8 +51,10 @@ services:
|
||||
# Email Processor Overrides
|
||||
- Email__Credentials__Password=${EMAIL_CREDENTIALS_PASSWORD:-}
|
||||
- Email__Credentials__Username=${EMAIL_CREDENTIALS_USERNAME:-}
|
||||
- Email__SenderEmail=${EMAIL_SENDER_EMAIL:-pfm@litecharms.co.za}
|
||||
- Email__SenderName=${EMAIL_SENDER_NAME:-Post Fund Management Updates}
|
||||
- Email__SmtpServer=${EMAIL_SMTP_SERVER:-}
|
||||
- Email__SmtpPort=${EMAIL_SMTP_PORT:-587}
|
||||
- Email__SmtpPort=${EMAIL_SMTP_PORT:-465}
|
||||
|
||||
# Redis overrides
|
||||
- ConnectionStrings__Redis=${REDIS_CONNECTION_STRING:-192.168.1.171:6379,ssl=false,abortConnect=false}
|
||||
|
||||
Reference in New Issue
Block a user