Skip to content

Commit

Permalink
Support setting SendGrid data residency region in gateway options.
Browse files Browse the repository at this point in the history
Closes #79.
  • Loading branch information
alexrp committed Jan 15, 2024
1 parent c3b86a2 commit 4b67b4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/server/gateway/Email/DelegatingSendGridClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ public string MediaType

public DelegatingSendGridClient(HttpClient client, IOptions<GatewayOptions> options)
{
var value = options.Value;

// If no API key is available, sending will just be a no-op.
if (options.Value.SendGridKey is { } key)
if (value.SendGridKey is { } key)
_client = new(
client,
new()
new SendGridClientOptions
{
ApiKey = key,
HttpErrorAsException = true,
});
}.SetDataResidency(value.SendGridRegion));
}

[RegisterServices]
Expand Down
2 changes: 2 additions & 0 deletions src/server/gateway/GatewayOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ internal sealed class GatewayOptions : IOptions<GatewayOptions>

public string? SendGridKey { get; set; }

public string SendGridRegion { get; set; } = "global";

public string EmailAddress { get; set; } = "arise@localhost";

public Duration AccountVerificationTime { get; set; } = Duration.FromDays(7);
Expand Down

0 comments on commit 4b67b4b

Please sign in to comment.