Compare commits
No commits in common. "90d04d7a4272e5771876f90f55e7b5572c83a0d7" and "a23953fe1168da7c6c19bd7eabc7611dac0fd434" have entirely different histories.
90d04d7a42
...
a23953fe11
@ -33,25 +33,13 @@ Log.Logger = loggerConfiguration
|
|||||||
.WriteTo.File("logs/portblog.txt", rollingInterval: RollingInterval.Day)
|
.WriteTo.File("logs/portblog.txt", rollingInterval: RollingInterval.Day)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
var urlsSection = builder.Configuration.GetSection("Urls");
|
var urls = builder.Configuration.GetSection("Urls");
|
||||||
var urlsValue = urlsSection.Value;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(urlsValue))
|
if (!string.IsNullOrEmpty(urls.Value))
|
||||||
{
|
{
|
||||||
var allowedUrlsToUse = urlsValue
|
var allowedUrlsToUse = urls.Value.Split(',');
|
||||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
|
||||||
.Where(u => Uri.IsWellFormedUriString(u, UriKind.Absolute))
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
if (allowedUrlsToUse.Length > 0)
|
|
||||||
{
|
|
||||||
builder.WebHost.UseUrls(allowedUrlsToUse);
|
builder.WebHost.UseUrls(allowedUrlsToUse);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// optionally log or throw depending on desired behavior
|
|
||||||
Log.Warning("Configured 'Urls' section was present but no valid URLs were found.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var allowedCorsOrigins = builder.Configuration.GetSection("AllowedCorsOrigins");
|
var allowedCorsOrigins = builder.Configuration.GetSection("AllowedCorsOrigins");
|
||||||
|
|||||||
@ -67,14 +67,16 @@ namespace PortBlog.API.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// Log full exception and persist failed message. Do not rethrow to avoid causing a 500 from OTP generation
|
logger.LogCritical(
|
||||||
logger.LogCritical(ex, "Exception while sending mail from {FromEmail} ({Name}).", messageSendDto.FromEmail, messageSendDto.Name);
|
"Exception while sending mail from {FromEmail} ({Name}): {Exception}",
|
||||||
|
messageSendDto.FromEmail,
|
||||||
|
messageSendDto.Name,
|
||||||
|
ex.Message
|
||||||
|
);
|
||||||
messageSendDto.SentStatus = (int)MailConstants.MailStatus.Failed;
|
messageSendDto.SentStatus = (int)MailConstants.MailStatus.Failed;
|
||||||
mailRepository.AddMessage(messageEntity);
|
mailRepository.AddMessage(messageEntity);
|
||||||
await mailRepository.SaveChangesAsync();
|
await mailRepository.SaveChangesAsync();
|
||||||
|
throw new Exception();
|
||||||
// swallow the exception so OTP generation continues; caller can inspect delivery status via message logs
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user