using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Wabbajack.DTOs.JsonConverters; using Wabbajack.Hashing.xxHash64; using Wabbajack.Server.DataLayer; namespace Wabbajack.BuildServer.Controllers { [Authorize(Roles = "User")] [ApiController] [Route("/mod_files")] public class ModFilesForHash : ControllerBase { private SqlService _sql; private ILogger _logger; private readonly DTOSerializer _dtos; public ModFilesForHash(ILogger logger, SqlService sql, DTOSerializer dtos) { _logger = logger; _sql = sql; _dtos = dtos; } [HttpGet("by_hash/{hashAsHex}")] public async Task GetByHash(string hashAsHex) { var files = await _sql.ResolveDownloadStatesByHash(Hash.FromHex(hashAsHex)); return Ok(_dtos.Serialize(files)); } } }