Send Non books to your Devices (#1691)
* Only restrict non-epub/pdf for Kindle devices on Send To. * Removed restriction to email non-epub/pdfs to devices.
This commit is contained in:
parent
ee5ea708d9
commit
b672cf545d
4 changed files with 81 additions and 20 deletions
|
@ -7,6 +7,7 @@ using API.DTOs.Device;
|
|||
using API.DTOs.Email;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Enums.Device;
|
||||
using API.SignalR;
|
||||
using Kavita.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -105,12 +106,14 @@ public class DeviceService : IDeviceService
|
|||
|
||||
public async Task<bool> SendTo(IReadOnlyList<int> chapterIds, int deviceId)
|
||||
{
|
||||
var files = await _unitOfWork.ChapterRepository.GetFilesForChaptersAsync(chapterIds);
|
||||
if (files.Any(f => f.Format is not (MangaFormat.Epub or MangaFormat.Pdf)))
|
||||
throw new KavitaException("Cannot Send non Epub or Pdf to devices as not supported");
|
||||
|
||||
var device = await _unitOfWork.DeviceRepository.GetDeviceById(deviceId);
|
||||
if (device == null) throw new KavitaException("Device doesn't exist");
|
||||
|
||||
var files = await _unitOfWork.ChapterRepository.GetFilesForChaptersAsync(chapterIds);
|
||||
if (files.Any(f => f.Format is not (MangaFormat.Epub or MangaFormat.Pdf)) && device.Platform == DevicePlatform.Kindle)
|
||||
throw new KavitaException("Cannot Send non Epub or Pdf to devices as not supported on Kindle");
|
||||
|
||||
|
||||
device.LastUsed = DateTime.Now;
|
||||
_unitOfWork.DeviceRepository.Update(device);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue