fix: Addressing PR comments
This commit is contained in:
parent
6498aa7fe5
commit
6e313dfffe
5 changed files with 15 additions and 6 deletions
|
|
@ -81,7 +81,12 @@ public class KoreaderController : BaseApiController
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets book progress from Kavita, if not found will return a 400
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="ebookHash"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{apiKey}/syncs/progress/{ebookHash}")]
|
||||
public async Task<ActionResult<KoreaderBookDto>> GetProgress(string apiKey, string ebookHash)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ namespace API.DTOs.Koreader;
|
|||
|
||||
public class KoreaderProgressUpdateDto
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the Koreader hash of the book. It is used to identify the book.
|
||||
/// </summary>
|
||||
public string Document { get; set; }
|
||||
/// <summary>
|
||||
/// UTC Timestamp to return to KOReader
|
||||
/// </summary>
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@ public class MangaFileRepository : IMangaFileRepository
|
|||
|
||||
return await _context.MangaFile
|
||||
.FirstOrDefaultAsync(f => f.KoreaderHash != null &&
|
||||
EF.Functions.Like(f.KoreaderHash, hash));
|
||||
f.KoreaderHash.Equals(hash.ToUpper()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ public class KoreaderBookDtoBuilder : IEntityBuilder<KoreaderBookDto>
|
|||
|
||||
public KoreaderBookDtoBuilder WithDeviceId(string installId, int userId)
|
||||
{
|
||||
using var sha256 = SHA256.Create();
|
||||
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(installId + userId));
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(installId + userId));
|
||||
_dto.Device_id = hash.ToString();
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ public class KoreaderService : IKoreaderService
|
|||
public async Task<KoreaderBookDto> GetProgress(string bookHash, int userId)
|
||||
{
|
||||
var settingsDto = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
var builder = new KoreaderBookDtoBuilder(bookHash);
|
||||
|
||||
var file = await _unitOfWork.MangaFileRepository.GetByKoreaderHash(bookHash);
|
||||
|
||||
|
|
@ -83,7 +82,7 @@ public class KoreaderService : IKoreaderService
|
|||
var progressDto = await _unitOfWork.AppUserProgressRepository.GetUserProgressDtoAsync(file.ChapterId, userId);
|
||||
var koreaderProgress = KoreaderHelper.GetKoreaderPosition(progressDto);
|
||||
|
||||
return builder.WithProgress(koreaderProgress)
|
||||
return new KoreaderBookDtoBuilder(bookHash).WithProgress(koreaderProgress)
|
||||
.WithPercentage(progressDto?.PageNum, file.Pages)
|
||||
.WithDeviceId(settingsDto.InstallId, userId)
|
||||
.Build();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue