From 309dcafa02532d3aff2196b25cad3ad840de3252 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 12 Oct 2024 11:59:10 +0500 Subject: [PATCH] monograph: add new id/view endpoint for self destruction --- .../Controllers/MonographsController.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Notesnook.API/Controllers/MonographsController.cs b/Notesnook.API/Controllers/MonographsController.cs index 024b4f7..d37e68e 100644 --- a/Notesnook.API/Controllers/MonographsController.cs +++ b/Notesnook.API/Controllers/MonographsController.cs @@ -36,6 +36,7 @@ namespace Notesnook.API.Controllers [Authorize("Sync")] public class MonographsController : ControllerBase { + const string SVG_PIXEL = ""; private Repository Monographs { get; set; } private readonly IUnitOfWork unit; private const int MAX_DOC_SIZE = 15 * 1024 * 1024; @@ -127,24 +128,17 @@ namespace Notesnook.API.Controllers return Ok(monograph); } - [HttpGet("{id}/destruct")] + [HttpGet("{id}/view")] [AllowAnonymous] - public async Task DestructMonographAsync([FromRoute] string id) + public async Task TrackView([FromRoute] string id) { var monograph = await Monographs.GetAsync(id); - if (monograph == null) - { - return NotFound(new - { - error = "invalid_id", - error_description = $"No such monograph found." - }); - } + if (monograph == null) return Content(SVG_PIXEL, "image/svg+xml"); if (monograph.SelfDestruct) await Monographs.DeleteByIdAsync(monograph.Id); - return Ok(); + return Content(SVG_PIXEL, "image/svg+xml"); } [HttpDelete("{id}")]