This commit is contained in:
Joe Milazzo 2024-11-16 09:20:28 -06:00 committed by GitHub
parent 6a75291a67
commit c849eff33e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 190 additions and 35 deletions

View file

@ -119,6 +119,11 @@ public class PersonController : BaseApiController
return Ok(_mapper.Map<PersonDto>(person));
}
/// <summary>
/// Attempts to download the cover from CoversDB (Note: Not yet release in Kavita)
/// </summary>
/// <param name="personId"></param>
/// <returns></returns>
[HttpPost("fetch-cover")]
public async Task<ActionResult<string>> DownloadCoverImage([FromQuery] int personId)
{
@ -129,13 +134,13 @@ public class PersonController : BaseApiController
var personImage = await _coverDbService.DownloadPersonImageAsync(person, settings.EncodeMediaAs);
if (string.IsNullOrEmpty(personImage)) return BadRequest(await _localizationService.Translate(User.GetUserId(), "person-image-doesnt-exist"));
person.CoverImage = personImage;
_imageService.UpdateColorScape(person);
_unitOfWork.PersonRepository.Update(person);
await _unitOfWork.CommitAsync();
await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate, MessageFactory.CoverUpdateEvent(person.Id, "person"), false);
return Ok(personImage);
}
@ -150,6 +155,12 @@ public class PersonController : BaseApiController
return Ok(await _unitOfWork.PersonRepository.GetSeriesKnownFor(personId));
}
/// <summary>
/// Returns all individual chapters by role. Limited to 20 results.
/// </summary>
/// <param name="personId"></param>
/// <param name="role"></param>
/// <returns></returns>
[HttpGet("chapters-by-role")]
public async Task<ActionResult<IEnumerable<StandaloneChapterDto>>> GetChaptersByRole(int personId, PersonRole role)
{