A boatload of Bugs (#3704)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
parent
ea9b7ad0d1
commit
37734554ba
102 changed files with 2051 additions and 1115 deletions
|
@ -50,7 +50,7 @@ public class BookController : BaseApiController
|
|||
case MangaFormat.Epub:
|
||||
{
|
||||
var mangaFile = (await _unitOfWork.ChapterRepository.GetFilesForChapterAsync(chapterId))[0];
|
||||
using var book = await EpubReader.OpenBookAsync(mangaFile.FilePath, BookService.BookReaderOptions);
|
||||
using var book = await EpubReader.OpenBookAsync(mangaFile.FilePath, BookService.LenientBookReaderOptions);
|
||||
bookTitle = book.Title;
|
||||
break;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class BookController : BaseApiController
|
|||
var chapter = await _unitOfWork.ChapterRepository.GetChapterAsync(chapterId);
|
||||
if (chapter == null) return BadRequest(await _localizationService.Get("en", "chapter-doesnt-exist"));
|
||||
|
||||
using var book = await EpubReader.OpenBookAsync(chapter.Files.ElementAt(0).FilePath, BookService.BookReaderOptions);
|
||||
using var book = await EpubReader.OpenBookAsync(chapter.Files.ElementAt(0).FilePath, BookService.LenientBookReaderOptions);
|
||||
var key = BookService.CoalesceKeyForAnyFile(book, file);
|
||||
|
||||
if (!book.Content.AllFiles.ContainsLocalFileRefWithKey(key)) return BadRequest(await _localizationService.Get("en", "file-missing"));
|
||||
|
|
|
@ -12,6 +12,7 @@ using API.Extensions;
|
|||
using API.Helpers;
|
||||
using API.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Controllers;
|
||||
|
||||
|
@ -24,11 +25,16 @@ public class FilterController : BaseApiController
|
|||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly IStreamService _streamService;
|
||||
private readonly ILogger<FilterController> _logger;
|
||||
|
||||
public FilterController(IUnitOfWork unitOfWork, ILocalizationService localizationService)
|
||||
public FilterController(IUnitOfWork unitOfWork, ILocalizationService localizationService, IStreamService streamService,
|
||||
ILogger<FilterController> logger)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_localizationService = localizationService;
|
||||
_streamService = streamService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -120,4 +126,57 @@ public class FilterController : BaseApiController
|
|||
{
|
||||
return Ok(SmartFilterHelper.Decode(dto.EncodedFilter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rename a Smart Filter given the filterId and new name
|
||||
/// </summary>
|
||||
/// <param name="filterId"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("rename")]
|
||||
public async Task<ActionResult> RenameFilter([FromQuery] int filterId, [FromQuery] string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(User.GetUserId(),
|
||||
AppUserIncludes.SmartFilters);
|
||||
if (user == null) return Unauthorized();
|
||||
|
||||
name = name.Trim();
|
||||
|
||||
if (User.IsInRole(PolicyConstants.ReadOnlyRole))
|
||||
{
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "permission-denied"));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "smart-filter-name-required"));
|
||||
}
|
||||
|
||||
if (Seed.DefaultStreams.Any(s => s.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)))
|
||||
{
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "smart-filter-system-name"));
|
||||
}
|
||||
|
||||
var filter = user.SmartFilters.FirstOrDefault(f => f.Id == filterId);
|
||||
if (filter == null)
|
||||
{
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "filter-not-found"));
|
||||
}
|
||||
|
||||
filter.Name = name;
|
||||
_unitOfWork.AppUserSmartFilterRepository.Update(filter);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
await _streamService.RenameSmartFilterStreams(filter);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "There was an exception when renaming smart filter: {FilterId}", filterId);
|
||||
return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-error"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,4 +204,30 @@ public class StreamController : BaseApiController
|
|||
await _streamService.UpdateSideNavStreamBulk(User.GetUserId(), dto);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a Smart Filter from a user's SideNav Streams
|
||||
/// </summary>
|
||||
/// <param name="sideNavStreamId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("smart-filter-side-nav-stream")]
|
||||
public async Task<ActionResult> DeleteSmartFilterSideNavStream([FromQuery] int sideNavStreamId)
|
||||
{
|
||||
if (User.IsInRole(PolicyConstants.ReadOnlyRole)) return BadRequest(await _localizationService.Translate(User.GetUserId(), "permission-denied"));
|
||||
await _streamService.DeleteSideNavSmartFilterStream(User.GetUserId(), sideNavStreamId);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a Smart Filter from a user's Dashboard Streams
|
||||
/// </summary>
|
||||
/// <param name="dashboardStreamId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("smart-filter-dashboard-stream")]
|
||||
public async Task<ActionResult> DeleteSmartFilterDashboardStream([FromQuery] int dashboardStreamId)
|
||||
{
|
||||
if (User.IsInRole(PolicyConstants.ReadOnlyRole)) return BadRequest(await _localizationService.Translate(User.GetUserId(), "permission-denied"));
|
||||
await _streamService.DeleteDashboardSmartFilterStream(User.GetUserId(), dashboardStreamId);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue