Added a new API for Panels so they can sync with a dedicated api. Removed ability to save progress with Panels.
This commit is contained in:
parent
0cf760ecd3
commit
c62e48f06a
3 changed files with 91 additions and 8 deletions
|
@ -1102,6 +1102,10 @@ public class OpdsController : BaseApiController
|
|||
Response.AddCacheHeader(content);
|
||||
|
||||
// Save progress for the user
|
||||
|
||||
var userAgent = Request.Headers["User-Agent"].ToString();
|
||||
if (!userAgent.Equals("panels", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
await _readerService.SaveReadingProgress(new ProgressDto()
|
||||
{
|
||||
ChapterId = chapterId,
|
||||
|
@ -1110,6 +1114,8 @@ public class OpdsController : BaseApiController
|
|||
VolumeId = volumeId,
|
||||
LibraryId =libraryId
|
||||
}, await GetUser(apiKey));
|
||||
}
|
||||
|
||||
|
||||
return File(content, MimeTypeMap.GetMimeType(format));
|
||||
}
|
||||
|
|
33
API/Controllers/PanelsController.cs
Normal file
33
API/Controllers/PanelsController.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.DTOs;
|
||||
using API.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// For the Panels app explicitly
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public class PanelsController : BaseApiController
|
||||
{
|
||||
private readonly IReaderService _readerService;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public PanelsController(IReaderService readerService, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_readerService = readerService;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
[HttpPost("save-progress")]
|
||||
public async Task<ActionResult> SaveProgress(ProgressDto dto, [FromQuery] string apiKey)
|
||||
{
|
||||
if (string.IsNullOrEmpty(apiKey)) return Unauthorized("ApiKey is required");
|
||||
var userId = await _unitOfWork.UserRepository.GetUserIdByApiKeyAsync(apiKey);
|
||||
await _readerService.SaveReadingProgress(dto, userId);
|
||||
return Ok();
|
||||
}
|
||||
}
|
46
openapi.json
46
openapi.json
|
@ -7,7 +7,7 @@
|
|||
"name": "GPL-3.0",
|
||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||
},
|
||||
"version": "0.7.9.4"
|
||||
"version": "0.7.10.0"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
|
@ -4168,6 +4168,46 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/Panels/save-progress": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Panels"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "apiKey",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProgressDto"
|
||||
}
|
||||
},
|
||||
"text/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProgressDto"
|
||||
}
|
||||
},
|
||||
"application/*+json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProgressDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Plugin/authenticate": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
@ -19687,6 +19727,10 @@
|
|||
"name": "Image",
|
||||
"description": "Responsible for servicing up images stored in Kavita for entities"
|
||||
},
|
||||
{
|
||||
"name": "Panels",
|
||||
"description": "For the Panels app explicitly"
|
||||
},
|
||||
{
|
||||
"name": "Rating",
|
||||
"description": "Responsible for providing external ratings for Series"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue