mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix build warnings and indentation (#4720)
This commit is contained in:
@@ -1860,7 +1860,7 @@ namespace BTCPayServer.Tests
|
|||||||
})
|
})
|
||||||
.ToHashSet();
|
.ToHashSet();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(1, formats.Count);
|
Assert.Single(formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -1324,32 +1324,31 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
public class UpdateLabelsRequest
|
public class UpdateLabelsRequest
|
||||||
{
|
{
|
||||||
public string Address { get; set; }
|
public string? Address { get; set; }
|
||||||
public string[]? Labels { get; set; }
|
public string[]? Labels { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{walletId}/update-labels")]
|
[HttpPost("{walletId}/update-labels")]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
public async Task<IActionResult> UpdateLabels( [ModelBinder(typeof(WalletIdModelBinder))] WalletId walletId, [FromBody] UpdateLabelsRequest request)
|
public async Task<IActionResult> UpdateLabels([ModelBinder(typeof(WalletIdModelBinder))] WalletId walletId, [FromBody] UpdateLabelsRequest request)
|
||||||
{
|
{
|
||||||
if (request.Address is null || request.Labels is null)
|
if (string.IsNullOrEmpty(request.Address) || request.Labels is null)
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
|
|
||||||
var objid = new WalletObjectId(walletId, WalletObjectData.Types.Address, request.Address);
|
var objid = new WalletObjectId(walletId, WalletObjectData.Types.Address, request.Address);
|
||||||
var obj = await WalletRepository.GetWalletObject(objid);
|
var obj = await WalletRepository.GetWalletObject(objid);
|
||||||
if (obj is null)
|
if (obj is null)
|
||||||
{
|
{
|
||||||
await WalletRepository.EnsureWalletObject(objid);
|
await WalletRepository.EnsureWalletObject(objid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var currentLabels = obj.GetNeighbours().Where(data => data.Type == WalletObjectData.Types.Label).ToArray();
|
var currentLabels = obj.GetNeighbours().Where(data => data.Type == WalletObjectData.Types.Label).ToArray();
|
||||||
var toRemove = currentLabels.Where(data => !request.Labels.Contains(data.Id)).Select(data => data.Id).ToArray();
|
var toRemove = currentLabels.Where(data => !request.Labels.Contains(data.Id)).Select(data => data.Id).ToArray();
|
||||||
await WalletRepository.RemoveWalletObjectLabels(objid, toRemove);
|
await WalletRepository.RemoveWalletObjectLabels(objid, toRemove);
|
||||||
}
|
}
|
||||||
await
|
await WalletRepository.AddWalletObjectLabels(objid, request.Labels);
|
||||||
WalletRepository.AddWalletObjectLabels(objid, request.Labels);
|
return Ok();
|
||||||
return Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{walletId}/labels")]
|
[HttpGet("{walletId}/labels")]
|
||||||
|
|||||||
Reference in New Issue
Block a user