Use JSON columns instead of junction tables

This commit is contained in:
Amelia 2025-06-01 22:47:12 +02:00
parent 8fd50d030b
commit b36f6c8f0b
35 changed files with 471 additions and 1103 deletions

View file

@ -612,7 +612,7 @@ public class AccountController : BaseApiController
}
/// <summary>
/// Requests the Invite Url for the UserId. Will return error if user is already validated.
/// Requests the Invite Url for the AppUserId. Will return error if user is already validated.
/// </summary>
/// <param name="userId"></param>
/// <param name="withBaseUrl">Include the "https://ip:port/" in the generated link</param>
@ -789,12 +789,10 @@ public class AccountController : BaseApiController
{
var profile = new AppUserReadingProfileBuilder(user.Id)
.WithName("Default Profile")
.WithKind(ReadingProfileKind.Default)
.Build();
_unitOfWork.AppUserReadingProfileRepository.Add(profile);
await _unitOfWork.CommitAsync();
user.UserPreferences.ReadingProfiles.Add(profile);
user.UserPreferences.DefaultReadingProfileId = profile.Id;
}
/// <summary>

View file

@ -45,7 +45,7 @@ public class PluginController(IUnitOfWork unitOfWork, ITokenService tokenService
throw new KavitaUnauthenticatedUserException();
}
var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId);
logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId);
logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({AppUserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId);
return new UserDto
{

View file

@ -26,10 +26,7 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
[HttpGet("all")]
public async Task<ActionResult<IList<UserReadingProfileDto>>> GetAllReadingProfiles()
{
var profiles = await unitOfWork.AppUserReadingProfileRepository
.GetProfilesDtoForUser(User.GetUserId(), true,
ReadingProfileIncludes.Series | ReadingProfileIncludes.Library);
var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesDtoForUser(User.GetUserId());
return Ok(profiles);
}
@ -42,7 +39,7 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
[HttpGet("{seriesId}")]
public async Task<ActionResult<UserReadingProfileDto>> GetProfileForSeries(int seriesId)
{
return Ok(await readingProfileService.GetReadingProfileForSeries(User.GetUserId(), seriesId));
return Ok(await readingProfileService.GetReadingProfileDtoForSeries(User.GetUserId(), seriesId));
}
/// <summary>
@ -85,20 +82,6 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
return Ok();
}
/// <summary>
/// Sets the given profile as the global default
/// </summary>
/// <param name="profileId"></param>
/// <returns></returns>
/// <exception cref="KavitaException"></exception>
/// <exception cref="UnauthorizedAccessException"></exception>
[HttpPost("set-default")]
public async Task<IActionResult> SetDefault([FromQuery] int profileId)
{
await readingProfileService.SetDefaultReadingProfile(User.GetUserId(), profileId);
return Ok();
}
/// <summary>
/// Deletes the given profile, requires the profile to belong to the logged-in user
/// </summary>