WebRTC Android et Linux + Admin refund + User UX @Post del
This commit is contained in:
parent
d812266ee0
commit
2e3f1af6f8
32 changed files with 1388 additions and 163 deletions
|
|
@ -0,0 +1,40 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Abstract.Resources;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
namespace Yavsc.ApiControllers.Administration;
|
||||
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = Constants.Administration)]
|
||||
[Authorize("AdministratorOnly")]
|
||||
[ResourceUsageExempt]
|
||||
[Route(Constants.APIPrefix + "/" + Constants.ResourceUsagePath + "/admin")]
|
||||
[Produces("application/json")]
|
||||
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
|
||||
public sealed class ResourceUsageReliefApiController(
|
||||
IResourceUsageService usage, ILogger<ResourceUsageReliefApiController> logger) : ControllerBase
|
||||
{
|
||||
[HttpPost("{userId}/erase")]
|
||||
[EndpointSummary("Effacer des points de consommation d’un utilisateur ayant atteint sa limite")]
|
||||
[EndpointDescription("Conserve les compteurs techniques, refuse les montants supérieurs à la consommation et les confirmations périmées, sans crédit futur.")]
|
||||
[ProducesResponseType<ResourceUsageSummary>(200)]
|
||||
[ProducesResponseType<ProblemDetails>(400)]
|
||||
[ProducesResponseType(401)]
|
||||
[ProducesResponseType(403)]
|
||||
[ProducesResponseType<ProblemDetails>(404)]
|
||||
[ProducesResponseType<ProblemDetails>(409)]
|
||||
public async Task<ActionResult<ResourceUsageSummary>> Erase(
|
||||
string userId, EraseResourceUsageRequest request, CancellationToken ct)
|
||||
{
|
||||
var actor = User.GetUserId();
|
||||
if (string.IsNullOrWhiteSpace(actor)) return Unauthorized();
|
||||
try { return Ok(await usage.EraseAsync(userId, actor, request, ct)); }
|
||||
catch (ResourceUsageAdjustmentException error)
|
||||
{
|
||||
logger.LogWarning("Point relief rejected for administrator {ActorUserId}, user {UserId}: {Reason}",
|
||||
actor, userId, error.Message);
|
||||
return Problem(statusCode: error.StatusCode, title: error.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
@baseUrl = https://localhost:5104
|
||||
@token = replace-with-access-token
|
||||
@userId = replace-with-user-id
|
||||
|
||||
### Current user's cumulative counters, indicator and effective quota (also accessible at the limit)
|
||||
GET {{baseUrl}}/api/v1/resource-usage/me
|
||||
|
|
@ -12,3 +13,25 @@ Authorization: Bearer {{token}}
|
|||
### Consuming operation: returns 429 Problem Details when quota is exhausted
|
||||
GET {{baseUrl}}/api/v1/notifications/me
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### Erase points for an exhausted user (administrator only; exempt from quota)
|
||||
# ExpectedCredits = AppliedCredits + CreditBalance from the latest overview.
|
||||
# Returns 409 for stale credits, a non-exhausted user or an amount above consumption.
|
||||
POST {{baseUrl}}/api/v1/resource-usage/admin/{{userId}}/erase
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"points": 100,
|
||||
"expectedCredits": 0
|
||||
}
|
||||
|
||||
### Unknown target: 404 (administrator token required)
|
||||
POST {{baseUrl}}/api/v1/resource-usage/admin/missing-user/erase
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"points": 100,
|
||||
"expectedCredits": 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue