mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Greenfield: Lightning addresses API (#4546)
* Greenfield: Lightning addresses API * add docs * Apply suggestions from code review Co-authored-by: d11n <mail@dennisreimann.de>
This commit is contained in:
@@ -60,8 +60,9 @@ public class LightningAddressService
|
||||
|
||||
public async Task<bool> Set(LightningAddressData data)
|
||||
{
|
||||
data.Username = NormalizeUsername(data.Username);
|
||||
await using var context = _applicationDbContextFactory.CreateContext();
|
||||
var result = (await GetCore(context, new LightningAddressQuery() { Usernames = new[] { data.Username } }))
|
||||
var result = (await GetCore(context, new LightningAddressQuery() { Usernames = new[] { data.Username} }))
|
||||
.FirstOrDefault();
|
||||
if (result is not null)
|
||||
{
|
||||
@@ -73,7 +74,6 @@ public class LightningAddressService
|
||||
context.Remove(result);
|
||||
}
|
||||
|
||||
data.Username = NormalizeUsername(data.Username);
|
||||
await context.AddAsync(data);
|
||||
await context.SaveChangesAsync();
|
||||
_memoryCache.Remove(GetKey(data.Username));
|
||||
@@ -82,6 +82,7 @@ public class LightningAddressService
|
||||
|
||||
public async Task<bool> Remove(string username, string? storeId = null)
|
||||
{
|
||||
username = NormalizeUsername(username);
|
||||
await using var context = _applicationDbContextFactory.CreateContext();
|
||||
var x = (await GetCore(context, new LightningAddressQuery() { Usernames = new[] { username } })).FirstOrDefault();
|
||||
if (x is null)
|
||||
|
||||
Reference in New Issue
Block a user