Redirect emails to dev address in non-production; fix PAID stamp color
- EmailService: add RedirectIfNonProd() mirroring SmsService pattern; reads SendGrid:DevRedirectEmail and redirects all outbound email in non-production so real customers are never contacted on local/dev - appsettings.json: set DevRedirectEmail to spouliot@scppowdercoating.com - PdfService: revert Opacity() (not in QuestPDF 2024.12.3); use Colors.Green.Lighten2 for stamp + border to achieve lighter look Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,8 @@ public class EmailService : IEmailService
|
||||
if (!_hostEnvironment.IsProduction())
|
||||
subject = $"[{_hostEnvironment.EnvironmentName}] {subject}";
|
||||
|
||||
(toEmail, toName) = RedirectIfNonProd(toEmail, toName);
|
||||
|
||||
var fromEmail = _configuration["SendGrid:FromEmail"] ?? "noreply@example.com";
|
||||
var fromName = _configuration["SendGrid:FromName"] ?? "Powder Coating";
|
||||
|
||||
@@ -104,6 +106,8 @@ public class EmailService : IEmailService
|
||||
if (!_hostEnvironment.IsProduction())
|
||||
subject = $"[{_hostEnvironment.EnvironmentName}] {subject}";
|
||||
|
||||
(toEmail, toName) = RedirectIfNonProd(toEmail, toName);
|
||||
|
||||
var fromEmail = _configuration["SendGrid:FromEmail"] ?? "noreply@example.com";
|
||||
var fromName = _configuration["SendGrid:FromName"] ?? "Powder Coating";
|
||||
|
||||
@@ -138,6 +142,20 @@ public class EmailService : IEmailService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In non-production environments, redirects outbound email to <c>SendGrid:DevRedirectEmail</c>
|
||||
/// so real customers are never contacted outside of production. Double-gated on environment
|
||||
/// name AND the config value so a misconfigured prod deploy can't accidentally redirect.
|
||||
/// </summary>
|
||||
private (string email, string name) RedirectIfNonProd(string toEmail, string toName)
|
||||
{
|
||||
if (_hostEnvironment.IsProduction()) return (toEmail, toName);
|
||||
var devEmail = _configuration["SendGrid:DevRedirectEmail"];
|
||||
if (string.IsNullOrWhiteSpace(devEmail)) return (toEmail, toName);
|
||||
_logger.LogWarning("Non-production environment: redirecting email from {Original} to dev address {Dev}", toEmail, devEmail);
|
||||
return (devEmail, $"[DEV → {toName} <{toEmail}>]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the built SendGrid message and interprets the HTTP response. Extracted so both
|
||||
/// send methods share identical dispatch and logging logic.
|
||||
|
||||
Reference in New Issue
Block a user