Skip to content

Commit

Permalink
Fix email settings on store level, when server has no email settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Jul 2, 2024
1 parent 05f3539 commit 120b90b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BTCPayServer.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@ await settings.UpdateSetting(new EmailSettings()
Password = "[email protected]",
Port = 1234,
Server = "store.com"
}), "", true));
}), ""));

Assert.Equal("[email protected]", (await Assert.IsType<StoreEmailSender>(await emailSenderFactory.GetEmailSender(acc.StoreId)).GetEmailSettings()).Login);
}
Expand Down
3 changes: 2 additions & 1 deletion BTCPayServer/Controllers/UIStoresController.Email.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ public async Task<IActionResult> StoreEmailSettings(string storeId, EmailsViewMo
if (store == null)
return NotFound();

ViewBag.UseCustomSMTP = useCustomSMTP;
model.FallbackSettings = await _emailSenderFactory.GetEmailSender(store.Id) is StoreEmailSender { FallbackSender: not null } storeSender
? await storeSender.FallbackSender.GetEmailSettings()
: null;
if (model.FallbackSettings is null) useCustomSMTP = true;
ViewBag.UseCustomSMTP = useCustomSMTP;
if (useCustomSMTP)
{
model.Settings.Validate("Settings.", ModelState);
Expand Down
1 change: 1 addition & 0 deletions BTCPayServer/Views/UIStores/StoreEmailSettings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
}
else
{
<input type="hidden" name="UseCustomSMTP" value="true" />
<partial name="EmailsBody" model="Model" />
}

Expand Down

0 comments on commit 120b90b

Please sign in to comment.