v0.8.6.1 - A few small issues Hotfix (#3744)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
Co-authored-by: Weblate (bot) <hosted@weblate.org>
Co-authored-by: Lyrq <lyrq.ku@gmail.com>
This commit is contained in:
Joe Milazzo 2025-04-18 05:48:37 -06:00 committed by GitHub
parent 00b759e532
commit ad152aa26a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 159 additions and 38 deletions

View file

@ -1,4 +1,6 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using API.Constants;
using API.Data;
using API.Data.Repositories;
using API.DTOs;
@ -54,4 +56,29 @@ public class VolumeController : BaseApiController
return Ok(false);
}
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("multiple")]
public async Task<ActionResult<bool>> DeleteMultipleVolumes(int[] volumesIds)
{
var volumes = await _unitOfWork.VolumeRepository.GetVolumesById(volumesIds);
if (volumes.Count != volumesIds.Length)
{
return BadRequest(_localizationService.Translate(User.GetUserId(), "volume-doesnt-exist"));
}
_unitOfWork.VolumeRepository.Remove(volumes);
if (!await _unitOfWork.CommitAsync())
{
return Ok(false);
}
foreach (var volume in volumes)
{
await _eventHub.SendMessageAsync(MessageFactory.VolumeRemoved, MessageFactory.VolumeRemovedEvent(volume.Id, volume.SeriesId), false);
}
return Ok(true);
}
}

View file

@ -35,6 +35,7 @@ public interface IVolumeRepository
void Add(Volume volume);
void Update(Volume volume);
void Remove(Volume volume);
void Remove(IList<Volume> volumes);
Task<IList<MangaFile>> GetFilesForVolume(int volumeId);
Task<string?> GetVolumeCoverImageAsync(int volumeId);
Task<IList<int>> GetChapterIdsByVolumeIds(IReadOnlyList<int> volumeIds);
@ -43,6 +44,7 @@ public interface IVolumeRepository
Task<VolumeDto?> GetVolumeDtoAsync(int volumeId, int userId);
Task<IEnumerable<Volume>> GetVolumesForSeriesAsync(IList<int> seriesIds, bool includeChapters = false);
Task<IEnumerable<Volume>> GetVolumes(int seriesId);
Task<IList<Volume>> GetVolumesById(IList<int> volumeIds, VolumeIncludes includes = VolumeIncludes.None);
Task<Volume?> GetVolumeByIdAsync(int volumeId);
Task<IList<Volume>> GetAllWithCoversInDifferentEncoding(EncodeFormat encodeFormat);
Task<IEnumerable<string>> GetCoverImagesForLockedVolumesAsync();
@ -72,6 +74,10 @@ public class VolumeRepository : IVolumeRepository
{
_context.Volume.Remove(volume);
}
public void Remove(IList<Volume> volumes)
{
_context.Volume.RemoveRange(volumes);
}
/// <summary>
/// Returns a list of non-tracked files for a given volume.
@ -180,6 +186,15 @@ public class VolumeRepository : IVolumeRepository
.OrderBy(vol => vol.MinNumber)
.ToListAsync();
}
public async Task<IList<Volume>> GetVolumesById(IList<int> volumeIds, VolumeIncludes includes = VolumeIncludes.None)
{
return await _context.Volume
.Where(vol => volumeIds.Contains(vol.Id))
.Includes(includes)
.AsSplitQuery()
.OrderBy(vol => vol.MinNumber)
.ToListAsync();
}
/// <summary>
/// Returns a single volume with Chapter and Files

View file

@ -204,8 +204,8 @@
"person-image-doesnt-exist": "Osoba nie istnieje w CoversDB",
"email-taken": "Adres e-mail jest już używany",
"kavitaplus-restricted": "Jest to dostępne tylko dla Kavita+",
"smart-filter-name-required": "Strona internetowa",
"sidenav-stream-only-delete-smart-filter": "Jedynie filtry filtrowe mogą zostać usunięte z SideNav",
"dashboard-stream-only-delete-smart-filter": "Tylko inteligentne strumienie filtrów mogą zostać usunięte z rozdzielczości",
"smart-filter-name-required": "Inteligentny filtr wymaga nazwy",
"sidenav-stream-only-delete-smart-filter": "Tylko inteligentne filtry mogą zostać usunięte z panelu bocznego",
"dashboard-stream-only-delete-smart-filter": "Tylko inteligentne strumienie filtrów może zostać usunięte z głównego panelu",
"smart-filter-system-name": "Nie można użyć nazwy systemu dostarczanego strumieniem"
}