New Year Bugs (#2513)
This commit is contained in:
parent
fcacd67d71
commit
5dfcccba7a
32 changed files with 230 additions and 142 deletions
|
@ -318,19 +318,18 @@ public class AccountController : BaseApiController
|
|||
[HttpPost("reset-api-key")]
|
||||
public async Task<ActionResult<string>> ResetApiKey()
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
if (user == null) throw new KavitaUnauthenticatedUserException();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername()) ?? throw new KavitaUnauthenticatedUserException();
|
||||
user.ApiKey = HashUtil.ApiKey();
|
||||
|
||||
if (_unitOfWork.HasChanges() && await _unitOfWork.CommitAsync())
|
||||
{
|
||||
await _eventHub.SendMessageToAsync(MessageFactory.UserUpdate,
|
||||
MessageFactory.UserUpdateEvent(user.Id, user.UserName), user.Id);
|
||||
return Ok(user.ApiKey);
|
||||
}
|
||||
|
||||
await _unitOfWork.RollbackAsync();
|
||||
return BadRequest(await _localizationService.Translate(User.GetUserId(), "unable-to-reset-key"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,8 +55,10 @@ public class ReviewController : BaseApiController
|
|||
public async Task<ActionResult<IEnumerable<UserReviewDto>>> GetReviews(int seriesId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var username = User.GetUsername();
|
||||
var userRatings = (await _unitOfWork.UserRepository.GetUserRatingDtosForSeriesAsync(seriesId, userId))
|
||||
.Where(r => !string.IsNullOrEmpty(r.Body) && !string.IsNullOrEmpty(r.Tagline))
|
||||
.Where(r => !string.IsNullOrEmpty(r.Body))
|
||||
.OrderByDescending(review => review.Username.Equals(username) ? 1 : 0)
|
||||
.ToList();
|
||||
if (!await _licenseService.HasActiveLicense())
|
||||
{
|
||||
|
@ -139,7 +141,7 @@ public class ReviewController : BaseApiController
|
|||
var rating = ratingBuilder
|
||||
.WithBody(dto.Body)
|
||||
.WithSeriesId(dto.SeriesId)
|
||||
.WithTagline(dto.Tagline)
|
||||
.WithTagline(string.Empty)
|
||||
.Build();
|
||||
|
||||
if (rating.Id == 0)
|
||||
|
@ -152,7 +154,7 @@ public class ReviewController : BaseApiController
|
|||
|
||||
|
||||
BackgroundJob.Enqueue(() =>
|
||||
_scrobblingService.ScrobbleReviewUpdate(user.Id, dto.SeriesId, dto.Tagline, dto.Body));
|
||||
_scrobblingService.ScrobbleReviewUpdate(user.Id, dto.SeriesId, string.Empty, dto.Body));
|
||||
return Ok(_mapper.Map<UserReviewDto>(rating));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using API.DTOs.Scrobbling;
|
||||
using API.Services.Plus;
|
||||
|
||||
namespace API.DTOs.Recommendation;
|
||||
#nullable enable
|
||||
|
@ -19,4 +20,5 @@ public class ExternalSeriesDetailDto
|
|||
public string? Summary { get; set; }
|
||||
public int? VolumeCount { get; set; }
|
||||
public int? ChapterCount { get; set; }
|
||||
public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.AniList;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace API.DTOs.Recommendation;
|
||||
using API.Services.Plus;
|
||||
|
||||
namespace API.DTOs.Recommendation;
|
||||
#nullable enable
|
||||
|
||||
public class ExternalSeriesDto
|
||||
|
@ -9,4 +11,5 @@ public class ExternalSeriesDto
|
|||
public string? Summary { get; set; }
|
||||
public int? AniListId { get; set; }
|
||||
public long? MalId { get; set; }
|
||||
public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.AniList;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,5 @@ namespace API.DTOs.SeriesDetail;
|
|||
public class UpdateUserReviewDto
|
||||
{
|
||||
public int SeriesId { get; set; }
|
||||
[MaxLength(120)]
|
||||
public string? Tagline { get; set; }
|
||||
public string Body { get; set; }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public class UserReviewDto
|
|||
/// <summary>
|
||||
/// A tagline for the review
|
||||
/// </summary>
|
||||
/// <remarks>This is not possible to set as a local user</remarks>
|
||||
public string? Tagline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -28,6 +28,7 @@ public class RatingBuilder : IEntityBuilder<AppUserRating>
|
|||
|
||||
public RatingBuilder WithTagline(string? tagline)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tagline)) return this;
|
||||
_rating.Tagline = tagline;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public interface IScrobblingService
|
|||
Task CheckExternalAccessTokens();
|
||||
Task<bool> HasTokenExpired(int userId, ScrobbleProvider provider);
|
||||
Task ScrobbleRatingUpdate(int userId, int seriesId, float rating);
|
||||
Task ScrobbleReviewUpdate(int userId, int seriesId, string reviewTitle, string reviewBody);
|
||||
Task ScrobbleReviewUpdate(int userId, int seriesId, string? reviewTitle, string reviewBody);
|
||||
Task ScrobbleReadingUpdate(int userId, int seriesId);
|
||||
Task ScrobbleWantToReadUpdate(int userId, int seriesId, bool onWantToRead);
|
||||
|
||||
|
@ -185,8 +185,10 @@ public class ScrobblingService : IScrobblingService
|
|||
} ?? string.Empty;
|
||||
}
|
||||
|
||||
public async Task ScrobbleReviewUpdate(int userId, int seriesId, string reviewTitle, string reviewBody)
|
||||
public async Task ScrobbleReviewUpdate(int userId, int seriesId, string? reviewTitle, string reviewBody)
|
||||
{
|
||||
// Currently disabled until at least hardcover is implemented
|
||||
return;
|
||||
if (!await _licenseService.HasActiveLicense()) return;
|
||||
|
||||
var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId, SeriesIncludes.Metadata | SeriesIncludes.Library);
|
||||
|
|
|
@ -295,9 +295,9 @@ public class ProcessSeries : IProcessSeries
|
|||
if (series.Format == MangaFormat.Epub || series.Format == MangaFormat.Pdf && chapters.Count == 1)
|
||||
{
|
||||
series.Metadata.MaxCount = 1;
|
||||
} else if (series.Metadata.TotalCount == 1 && chapters.Count == 1 && chapters[0].IsSpecial)
|
||||
} else if (series.Metadata.TotalCount <= 1 && chapters.Count == 1 && chapters[0].IsSpecial)
|
||||
{
|
||||
// If a series has a TotalCount of 1 and there is only a Special, mark it as Complete
|
||||
// If a series has a TotalCount of 1 (or no total count) and there is only a Special, mark it as Complete
|
||||
series.Metadata.MaxCount = series.Metadata.TotalCount;
|
||||
} else if ((maxChapter == 0 || maxChapter > series.Metadata.TotalCount) && maxVolume <= series.Metadata.TotalCount)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue