Kavita+ Overhaul & New Changelog (#3507)
This commit is contained in:
parent
d880c1690c
commit
a5707617f2
249 changed files with 14775 additions and 2300 deletions
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs.Account;
|
||||
using API.DTOs.KavitaPlus.Account;
|
||||
using API.DTOs.Scrobbling;
|
||||
using API.Entities.Scrobble;
|
||||
using API.Extensions;
|
||||
|
|
@ -73,9 +74,9 @@ public class ScrobblingController : BaseApiController
|
|||
/// Update the current user's AniList token
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>True if the token was new or not</returns>
|
||||
[HttpPost("update-anilist-token")]
|
||||
public async Task<ActionResult> UpdateAniListToken(AniListUpdateDto dto)
|
||||
public async Task<ActionResult<bool>> UpdateAniListToken(AniListUpdateDto dto)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
if (user == null) return Unauthorized();
|
||||
|
|
@ -85,31 +86,39 @@ public class ScrobblingController : BaseApiController
|
|||
_unitOfWork.UserRepository.Update(user);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
if (isNewToken)
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _scrobblingService.CreateEventsFromExistingHistory(user.Id));
|
||||
}
|
||||
|
||||
return Ok();
|
||||
return Ok(isNewToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the current user's MAL token (Client ID) and Username
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>True if the token was new or not</returns>
|
||||
[HttpPost("update-mal-token")]
|
||||
public async Task<ActionResult> UpdateMalToken(MalUserInfoDto dto)
|
||||
public async Task<ActionResult<bool>> UpdateMalToken(MalUserInfoDto dto)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
if (user == null) return Unauthorized();
|
||||
|
||||
var isNewToken = string.IsNullOrEmpty(user.MalAccessToken);
|
||||
user.MalAccessToken = dto.AccessToken;
|
||||
user.MalUserName = dto.Username;
|
||||
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
return Ok(isNewToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When a user request to generate scrobble events from history. Should only be ran once per user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("generate-scrobble-events")]
|
||||
public ActionResult GenerateScrobbleEvents()
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _scrobblingService.CreateEventsFromExistingHistory(User.GetUserId()));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue