Updated email settings
This commit is contained in:
@@ -34,8 +34,6 @@ public sealed class LateProjectEventHandler(IDbContextFactory<ApplicationDbConte
|
|||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
var overdueCutoff = lateDays > 0 ? now.AddDays(-lateDays) : now;
|
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
|
var overdueMilestones = await context.Milestones
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(i => i.Project)
|
.Include(i => i.Project)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using PostFundManagement.Application.Abstractions.Services;
|
using PostFundManagement.Application.Abstractions.Services;
|
||||||
using PostFundManagement.Application.Services.Communications;
|
using PostFundManagement.Application.Services.Communications;
|
||||||
using PostFundManagement.Domain;
|
using PostFundManagement.Domain;
|
||||||
@@ -33,7 +31,6 @@ public sealed class NonCompliantProjectEventHandler(IDbContextFactory<Applicatio
|
|||||||
|
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
// Fetch active/monitored projects with programme, portfolio, and award organisations
|
|
||||||
var projects = await context.Projects
|
var projects = await context.Projects
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(p => p.Programme)
|
.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("[ConsoleUrl]", "https://console.ifri.khongisa.co.za");
|
||||||
messageBody = messageBody.Replace("[Year]", now.Year.ToString());
|
messageBody = messageBody.Replace("[Year]", now.Year.ToString());
|
||||||
|
|
||||||
var notificationRequest = new CreateNotificationRequest(
|
var notificationRequest = new CreateNotificationRequest(organisation.Id, recipientId, NotificationPlatform.Email,
|
||||||
organisation.Id,
|
$"[Audit Notice] Project Non-Compliance: {project.Name}", recipientEmail, messageBody, NotificationStatus.Queued);
|
||||||
recipientId,
|
|
||||||
NotificationPlatform.Email,
|
|
||||||
$"[Audit Notice] Project Non-Compliance: {project.Name}",
|
|
||||||
recipientEmail,
|
|
||||||
messageBody,
|
|
||||||
NotificationStatus.Queued);
|
|
||||||
|
|
||||||
_ = await service.CreateNotificationAsync(notificationRequest, SystemUser, cancellationToken);
|
_ = 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("[PortalUrl]", "https://partner.ifri.khongisa.co.za");
|
||||||
progMessageBody = progMessageBody.Replace("[Year]", now.Year.ToString());
|
progMessageBody = progMessageBody.Replace("[Year]", now.Year.ToString());
|
||||||
|
|
||||||
var progNotificationRequest = new CreateNotificationRequest(
|
var progNotificationRequest = new CreateNotificationRequest(organisation.Id, programmeManagerId.Value, NotificationPlatform.Email,
|
||||||
organisation.Id,
|
$"[Weekly Audit Escalation] Non-Compliant Project: {project.Name} ({programme?.Name})",
|
||||||
programmeManagerId.Value,
|
programmeManagerEmail, progMessageBody, NotificationStatus.Queued);
|
||||||
NotificationPlatform.Email,
|
|
||||||
$"[Weekly Audit Escalation] Non-Compliant Project: {project.Name} ({programme?.Name})",
|
|
||||||
programmeManagerEmail,
|
|
||||||
progMessageBody,
|
|
||||||
NotificationStatus.Queued);
|
|
||||||
|
|
||||||
_ = await service.CreateNotificationAsync(progNotificationRequest, SystemUser, cancellationToken);
|
_ = await service.CreateNotificationAsync(progNotificationRequest, SystemUser, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using PostFundManagement.Application.Services.Shared;
|
using PostFundManagement.Application.Services.Shared;
|
||||||
using PostFundManagement.Domain.Abstractions;
|
using PostFundManagement.Domain.Abstractions;
|
||||||
|
using PostFundManagement.Domain.Configuration.Email;
|
||||||
using PostFundManagement.Infrastructure.Database;
|
using PostFundManagement.Infrastructure.Database;
|
||||||
|
|
||||||
namespace PostFundManagement.Application.Events;
|
namespace PostFundManagement.Application.Events;
|
||||||
@@ -18,9 +19,10 @@ public sealed class ProcessEmailEvent : IEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbContext> contextFactory,
|
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;
|
const int maxBatch = 100;
|
||||||
|
readonly SmtpSettings emailSettings = options.Value;
|
||||||
|
|
||||||
public async ValueTask Handle(ProcessEmailEvent notification, CancellationToken cancellationToken)
|
public async ValueTask Handle(ProcessEmailEvent notification, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -74,8 +76,8 @@ public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbCont
|
|||||||
{
|
{
|
||||||
Sender = new Domain.Models.Email.Party
|
Sender = new Domain.Models.Email.Party
|
||||||
{
|
{
|
||||||
Address = "noreply@ifritechnologies.co.za",
|
Address = emailSettings.SenderEmail,
|
||||||
Name = "Post Fund Management"
|
Name = emailSettings.SenderName
|
||||||
},
|
},
|
||||||
Recipient = new Domain.Models.Email.Party
|
Recipient = new Domain.Models.Email.Party
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public sealed class SmtpSettings
|
|||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
|
|
||||||
public string? Host { get; set; }
|
public string? Host { get; set; }
|
||||||
|
|
||||||
|
public string? SenderEmail { get; set; }
|
||||||
|
|
||||||
|
public string? SenderName { get; set; }
|
||||||
|
|
||||||
public bool UseSsl { get; set; }
|
public bool UseSsl { get; set; }
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Email": {
|
"Email": {
|
||||||
"SmtpServer": "smtp.example.com",
|
"SmtpServer": "mail.litecharms.co.za",
|
||||||
"SmtpPort": 587,
|
"SmtpPort": 465,
|
||||||
"SenderEmail": "noreply@example.com",
|
"SenderEmail": "pfm@litecharms.co.za",
|
||||||
"SenderName": "Example"
|
"SenderName": "Post Fund Management Updates"
|
||||||
},
|
},
|
||||||
"HasherSettings": {
|
"HasherSettings": {
|
||||||
"MinHashLength": 11
|
"MinHashLength": 11
|
||||||
|
|||||||
+3
-1
@@ -51,8 +51,10 @@ services:
|
|||||||
# Email Processor Overrides
|
# Email Processor Overrides
|
||||||
- Email__Credentials__Password=${EMAIL_CREDENTIALS_PASSWORD:-}
|
- Email__Credentials__Password=${EMAIL_CREDENTIALS_PASSWORD:-}
|
||||||
- Email__Credentials__Username=${EMAIL_CREDENTIALS_USERNAME:-}
|
- 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__SmtpServer=${EMAIL_SMTP_SERVER:-}
|
||||||
- Email__SmtpPort=${EMAIL_SMTP_PORT:-587}
|
- Email__SmtpPort=${EMAIL_SMTP_PORT:-465}
|
||||||
|
|
||||||
# Redis overrides
|
# Redis overrides
|
||||||
- ConnectionStrings__Redis=${REDIS_CONNECTION_STRING:-192.168.1.171:6379,ssl=false,abortConnect=false}
|
- ConnectionStrings__Redis=${REDIS_CONNECTION_STRING:-192.168.1.171:6379,ssl=false,abortConnect=false}
|
||||||
|
|||||||
Reference in New Issue
Block a user