Smart Filter Encoding Fix (#2387)

This commit is contained in:
Joe Milazzo 2023-11-02 08:35:43 -05:00 committed by GitHub
parent b6d4938e22
commit 9894a2623c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
133 changed files with 677 additions and 471 deletions

View file

@ -29,6 +29,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
/// <summary>
/// All Account matters
/// </summary>

View file

@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
public class AdminController : BaseApiController
{
private readonly UserManager<AppUser> _userManager;

View file

@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
[ApiController]
[Route("api/[controller]")]
[Authorize]

View file

@ -14,6 +14,8 @@ using VersOne.Epub;
namespace API.Controllers;
#nullable enable
public class BookController : BaseApiController
{
private readonly IBookService _bookService;

View file

@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for the CBL import flow
/// </summary>

View file

@ -13,6 +13,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// APIs for Collections
/// </summary>

View file

@ -12,6 +12,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible interacting and creating Devices
/// </summary>

View file

@ -16,6 +16,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
/// <summary>
/// All APIs related to downloading entities from the system. Requires Download Role or Admin Role.
/// </summary>

View file

@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
[AllowAnonymous]
public class FallbackController : Controller
{

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.Constants;
using API.Data;
using API.Data.Repositories;
using API.DTOs.Dashboard;
@ -10,23 +9,22 @@ using API.DTOs.Filtering.v2;
using API.Entities;
using API.Extensions;
using API.Helpers;
using EasyCaching.Core;
using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// This is responsible for Filter caching
/// </summary>
public class FilterController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;
private readonly IEasyCachingProviderFactory _cacheFactory;
public FilterController(IUnitOfWork unitOfWork, IEasyCachingProviderFactory cacheFactory)
public FilterController(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
_cacheFactory = cacheFactory;
}
/// <summary>
@ -93,4 +91,26 @@ public class FilterController : BaseApiController
await _unitOfWork.CommitAsync();
return Ok();
}
/// <summary>
/// Encode the Filter
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("encode")]
public ActionResult<string> EncodeFilter(FilterV2Dto dto)
{
return Ok(SmartFilterHelper.Encode(dto));
}
/// <summary>
/// Decodes the Filter
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("decode")]
public ActionResult<FilterV2Dto> DecodeFilter(DecodeFilterDto dto)
{
return Ok(SmartFilterHelper.Decode(dto.EncodedFilter));
}
}

View file

@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
[AllowAnonymous]
public class HealthController : BaseApiController
{

View file

@ -13,6 +13,8 @@ using MimeTypes;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for servicing up images stored in Kavita for entities
/// </summary>

View file

@ -27,6 +27,8 @@ using TaskScheduler = API.Services.TaskScheduler;
namespace API.Controllers;
#nullable enable
[Authorize]
public class LibraryController : BaseApiController
{

View file

@ -15,6 +15,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class LicenseController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;

View file

@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
public class LocaleController : BaseApiController
{
private readonly ILocalizationService _localizationService;

View file

@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
public class MetadataController : BaseApiController
{

View file

@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// For the Panels app explicitly
/// </summary>

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using API.Data;
using API.DTOs;
@ -11,6 +12,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class PluginController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;
@ -43,7 +46,7 @@ public class PluginController : BaseApiController
var userId = await _unitOfWork.UserRepository.GetUserIdByApiKeyAsync(apiKey);
if (userId <= 0)
{
_logger.LogInformation("A Plugin ({PluginName}) tried to authenticate with an apiKey that doesn't match. Information {Information}", pluginName, new
_logger.LogInformation("A Plugin ({PluginName}) tried to authenticate with an apiKey that doesn't match. Information {@Information}", Uri.EscapeDataString(pluginName), new
{
IpAddress = ipAddress,
UserAgent = userAgent,
@ -52,7 +55,7 @@ public class PluginController : BaseApiController
throw new KavitaUnauthenticatedUserException();
}
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);
_logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", pluginName, user!.UserName, userId);
_logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", Uri.EscapeDataString(pluginName), user!.UserName, userId);
return new UserDto
{
Username = user.UserName!,

View file

@ -13,6 +13,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for providing external ratings for Series
/// </summary>

View file

@ -26,6 +26,8 @@ using MimeTypes;
namespace API.Controllers;
#nullable enable
/// <summary>
/// For all things regarding reading, mainly focusing on non-Book related entities
/// </summary>

View file

@ -16,6 +16,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
[Authorize]
public class ReadingListController : BaseApiController
{

View file

@ -17,6 +17,8 @@ using Newtonsoft.Json;
namespace API.Controllers;
#nullable enable
public class RecommendedController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;

View file

@ -18,6 +18,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class ReviewController : BaseApiController
{
private readonly ILogger<ReviewController> _logger;

View file

@ -21,6 +21,7 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class ScrobblingController : BaseApiController
{

View file

@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for the Search interface from the UI
/// </summary>

View file

@ -28,6 +28,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class SeriesController : BaseApiController
{
private readonly ILogger<SeriesController> _logger;

View file

@ -20,13 +20,14 @@ using Hangfire.Storage;
using Kavita.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using MimeTypes;
using TaskScheduler = API.Services.TaskScheduler;
namespace API.Controllers;
#nullable enable
[Authorize(Policy = "RequireAdminRole")]
public class ServerController : BaseApiController
{
@ -286,8 +287,6 @@ public class ServerController : BaseApiController
if (emailServiceUrl.Equals(EmailService.DefaultApiUrl)) return Ok(null);
return Ok(await _emailService.GetVersion(emailServiceUrl));
}
}

View file

@ -24,6 +24,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
public class SettingsController : BaseApiController
{
private readonly ILogger<SettingsController> _logger;

View file

@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
public class StatsController : BaseApiController
{
private readonly IStatisticService _statService;

View file

@ -10,6 +10,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for anything that deals with Streams (SmartFilters, ExternalSource, DashboardStream, SideNavStream)
/// </summary>

View file

@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// All APIs are for Tachiyomi extension and app. They have hacks for our implementation and should not be used for any
/// other purposes.

View file

@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
public class ThemeController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;

View file

@ -13,6 +13,8 @@ using Microsoft.Extensions.Logging;
namespace API.Controllers;
#nullable enable
/// <summary>
///
/// </summary>

View file

@ -13,6 +13,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
[Authorize]
public class UsersController : BaseApiController
{

View file

@ -16,6 +16,8 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers;
#nullable enable
/// <summary>
/// Responsible for all things Want To Read
/// </summary>
@ -42,7 +44,7 @@ public class WantToReadController : BaseApiController
/// <returns></returns>
[HttpPost]
[Obsolete("use v2 instead")]
public async Task<ActionResult<PagedList<SeriesDto>>> GetWantToRead([FromQuery] UserParams userParams, FilterDto filterDto)
public async Task<ActionResult<PagedList<SeriesDto>>> GetWantToRead([FromQuery] UserParams? userParams, FilterDto filterDto)
{
userParams ??= new UserParams();
var pagedList = await _unitOfWork.SeriesRepository.GetWantToReadForUserAsync(User.GetUserId(), userParams, filterDto);
@ -60,7 +62,7 @@ public class WantToReadController : BaseApiController
/// <param name="filterDto"></param>
/// <returns></returns>
[HttpPost("v2")]
public async Task<ActionResult<PagedList<SeriesDto>>> GetWantToReadV2([FromQuery] UserParams userParams, FilterV2Dto filterDto)
public async Task<ActionResult<PagedList<SeriesDto>>> GetWantToReadV2([FromQuery] UserParams? userParams, FilterV2Dto filterDto)
{
userParams ??= new UserParams();
var pagedList = await _unitOfWork.SeriesRepository.GetWantToReadForUserV2Async(User.GetUserId(), userParams, filterDto);