mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
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
@ -7,6 +7,7 @@ using API.DTOs.Device;
|
|||||||
using API.DTOs.Email;
|
using API.DTOs.Email;
|
||||||
using API.Entities;
|
using API.Entities;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
|
using API.Entities.Enums.Device;
|
||||||
using API.SignalR;
|
using API.SignalR;
|
||||||
using Kavita.Common;
|
using Kavita.Common;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -105,12 +106,14 @@ public class DeviceService : IDeviceService
|
|||||||
|
|
||||||
public async Task<bool> SendTo(IReadOnlyList<int> chapterIds, int deviceId)
|
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);
|
var device = await _unitOfWork.DeviceRepository.GetDeviceById(deviceId);
|
||||||
if (device == null) throw new KavitaException("Device doesn't exist");
|
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;
|
device.LastUsed = DateTime.Now;
|
||||||
_unitOfWork.DeviceRepository.Update(device);
|
_unitOfWork.DeviceRepository.Update(device);
|
||||||
await _unitOfWork.CommitAsync();
|
await _unitOfWork.CommitAsync();
|
||||||
|
@ -174,10 +174,10 @@ export class ActionFactoryService {
|
|||||||
dummyCallback(action: ActionItem<any>, data: any) {}
|
dummyCallback(action: ActionItem<any>, data: any) {}
|
||||||
|
|
||||||
filterSendToAction(actions: Array<ActionItem<Chapter>>, chapter: Chapter) {
|
filterSendToAction(actions: Array<ActionItem<Chapter>>, chapter: Chapter) {
|
||||||
if (chapter.files.filter(f => f.format === MangaFormat.EPUB || f.format === MangaFormat.PDF).length !== chapter.files.length) {
|
// if (chapter.files.filter(f => f.format === MangaFormat.EPUB || f.format === MangaFormat.PDF).length !== chapter.files.length) {
|
||||||
// Remove Send To as it doesn't apply
|
// // Remove Send To as it doesn't apply
|
||||||
return actions.filter(item => item.title !== 'Send To');
|
// return actions.filter(item => item.title !== 'Send To');
|
||||||
}
|
// }
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,9 +319,9 @@ export class CardItemComponent implements OnInit, OnDestroy {
|
|||||||
this.actions = this.actionFactoryService.filterSendToAction(this.actions, vol.chapters[0]);
|
this.actions = this.actionFactoryService.filterSendToAction(this.actions, vol.chapters[0]);
|
||||||
} else if (this.utilityService.isSeries(this.entity)) {
|
} else if (this.utilityService.isSeries(this.entity)) {
|
||||||
const series = (this.entity as Series);
|
const series = (this.entity as Series);
|
||||||
if (series.format === MangaFormat.EPUB || series.format === MangaFormat.PDF) {
|
// if (series.format === MangaFormat.EPUB || series.format === MangaFormat.PDF) {
|
||||||
this.actions = this.actions.filter(a => a.title !== 'Send To');
|
// this.actions = this.actions.filter(a => a.title !== 'Send To');
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
76
openapi.json
76
openapi.json
@ -7,7 +7,7 @@
|
|||||||
"name": "GPL-3.0",
|
"name": "GPL-3.0",
|
||||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||||
},
|
},
|
||||||
"version": "0.6.1.10"
|
"version": "0.6.1.11"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
@ -3485,6 +3485,66 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/Reader/file-dimensions": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Reader"
|
||||||
|
],
|
||||||
|
"summary": "Returns the file dimensions for all pages in a chapter. If the underlying chapter is PDF, use extractPDF to unpack as images.",
|
||||||
|
"description": "This has a side effect of caching the images.\r\n This will only be populated on archive filetypes and not in bookmark mode",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "chapterId",
|
||||||
|
"in": "query",
|
||||||
|
"description": "",
|
||||||
|
"schema": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "extractPdf",
|
||||||
|
"in": "query",
|
||||||
|
"description": "",
|
||||||
|
"schema": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"content": {
|
||||||
|
"text/plain": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/FileDimensionDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/FileDimensionDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"text/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/FileDimensionDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/Reader/chapter-info": {
|
"/api/Reader/chapter-info": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -9829,14 +9889,6 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Series Title",
|
"description": "Series Title",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
|
||||||
"fileDimensions": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/FileDimensionDto"
|
|
||||||
},
|
|
||||||
"description": "A list of images and their dimensions to be used with double page readers",
|
|
||||||
"nullable": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@ -10253,6 +10305,12 @@
|
|||||||
"pageNumber": {
|
"pageNumber": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int32"
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"fileName": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The filename of the cached file. If this was nested in a subfolder, the foldername will be appended with _",
|
||||||
|
"nullable": true,
|
||||||
|
"example": "chapter01_page01.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user