Skip to content

Commit

Permalink
fix: null check
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanho committed Sep 14, 2023
1 parent d8ff521 commit 6ff20eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Postal.AspNetCore/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<MailMessage> CreateMailMessageAsync(Email email)
var rawEmailString = await emailViewRenderer.RenderAsync(email);
emailParser = new EmailParser(emailViewRenderer);
var mailMessage = await emailParser.ParseAsync(rawEmailString, email);
if (mailMessage.From == null || mailMessage.From.Address == null)
if ((mailMessage.From == null || mailMessage.From.Address == null) && this.options.FromAddress != null)
{
mailMessage.From = new MailAddress(this.options.FromAddress);
}
Expand Down
7 changes: 5 additions & 2 deletions src/Postal.AspNetCore/TemplateServices/TemplateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ DiagnosticListener diagnosticListener
{
RequestServices = _serviceProvider,
};
httpContext.Features.Set<IEndpointFeature>(new EndpointFeature(httpContextData.Endpoint));
httpContext.Features.Set<IRouteValuesFeature>(new RouteValuesFeature() { RouteValues = httpContextData.RouteValues });
if (httpContextData != null)
{
httpContext.Features.Set<IEndpointFeature>(new EndpointFeature(httpContextData.Endpoint));
httpContext.Features.Set<IRouteValuesFeature>(new RouteValuesFeature() { RouteValues = httpContextData.RouteValues });
}

if (viewModel.RequestPath != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Postal.Tests/EmailViewRenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public FakeView(Func<ViewContext, string> templateString)
TemplateString = templateString;
}

public string Path => throw new NotImplementedException();
public string Path => "FakePathUnitTest";

public Func<ViewContext, string> TemplateString { get; private set; }

Expand Down
3 changes: 2 additions & 1 deletion src/Postal.Tests/Postal.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
<None Update="postal.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup></Project>
</ItemGroup>
</Project>

0 comments on commit 6ff20eb

Please sign in to comment.