mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Refactored Stats code to be much cleaner and user better naming. * Cleaned up the actual http code to use Flurl and to return if the upload was successful or not so we can delete the file where appropriate. * More refactoring for the stats code to clean it up and keep it consistent with our standards. * Removed a confusing log statement * Added support for old api key header from original stat server * Use the correct endpoint, not the new one. * Code smell
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using API.DTOs.Stats;
|
|
using API.Interfaces.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace API.Controllers
|
|
{
|
|
public class StatsController : BaseApiController
|
|
{
|
|
private readonly ILogger<StatsController> _logger;
|
|
private readonly IStatsService _statsService;
|
|
|
|
public StatsController(ILogger<StatsController> logger, IStatsService statsService)
|
|
{
|
|
_logger = logger;
|
|
_statsService = statsService;
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[HttpPost("client-info")]
|
|
public async Task<IActionResult> AddClientInfo([FromBody] ClientInfoDto clientInfoDto)
|
|
{
|
|
try
|
|
{
|
|
await _statsService.RecordClientInfo(clientInfoDto);
|
|
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error updating the usage statistics");
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|