2757869176
Add contract validation, SMTP delivery results, terminal failure context, neutral development seeding, and local Docker setup. Ref: IT-1033
23 lines
729 B
C#
23 lines
729 B
C#
namespace HrynCo.NotificationService.Worker.Services.EmailProcessing;
|
|
|
|
public static class RecipientAddressRedactor
|
|
{
|
|
public static string Redact(string? address)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(address))
|
|
return "<missing>";
|
|
|
|
int separator = address.LastIndexOf('@');
|
|
if (separator <= 0 || separator == address.Length - 1)
|
|
return "***";
|
|
|
|
string local = address[..separator];
|
|
string domain = address[(separator + 1)..];
|
|
int dot = domain.LastIndexOf('.');
|
|
string domainName = dot > 0 ? domain[..dot] : domain;
|
|
string suffix = dot > 0 ? domain[dot..] : string.Empty;
|
|
|
|
return $"{local[0]}***@{domainName[0]}***{suffix}";
|
|
}
|
|
}
|