wabbajack/Wabbajack.Server/Controllers/ModFiles.cs

35 lines
1.0 KiB
C#
Raw Normal View History

2020-06-21 22:03:54 +00:00
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
2021-09-27 12:42:46 +00:00
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Hashing.xxHash64;
2020-06-21 22:03:54 +00:00
using Wabbajack.Server.DataLayer;
namespace Wabbajack.BuildServer.Controllers
{
[Authorize(Roles = "User")]
[ApiController]
[Route("/mod_files")]
2021-09-27 12:42:46 +00:00
public class ModFilesForHash : ControllerBase
2020-06-21 22:03:54 +00:00
{
private SqlService _sql;
2021-09-27 12:42:46 +00:00
private ILogger<ModFilesForHash> _logger;
private readonly DTOSerializer _dtos;
2020-06-21 22:03:54 +00:00
2021-09-27 12:42:46 +00:00
public ModFilesForHash(ILogger<ModFilesForHash> logger, SqlService sql, DTOSerializer dtos)
2020-06-21 22:03:54 +00:00
{
_logger = logger;
_sql = sql;
2021-09-27 12:42:46 +00:00
_dtos = dtos;
2020-06-21 22:03:54 +00:00
}
[HttpGet("by_hash/{hashAsHex}")]
public async Task<IActionResult> GetByHash(string hashAsHex)
{
var files = await _sql.ResolveDownloadStatesByHash(Hash.FromHex(hashAsHex));
2021-09-27 12:42:46 +00:00
return Ok(_dtos.Serialize(files));
2020-06-21 22:03:54 +00:00
}
}
}