monographs: add stats endpoint (#69)

* also don't mark monograph for sync when tracking view count
This commit is contained in:
01zulfi
2025-11-07 10:28:03 +05:00
committed by GitHub
parent 7a8873db32
commit 23b0b2ddfc

View File

@@ -267,13 +267,25 @@ namespace Notesnook.API.Controllers
Expires = DateTimeOffset.UtcNow.AddMonths(1)
};
Response.Cookies.Append(cookieName, "1", cookieOptions);
await MarkMonographForSyncAsync(monograph.UserId, id);
}
return Content(SVG_PIXEL, "image/svg+xml");
}
[HttpGet("{id}/stats")]
public async Task<IActionResult> GetMonographStatsAsync([FromRoute] string id)
{
var userId = this.User.GetUserId();
var monograph = await FindMonographAsync(id);
if (monograph == null || monograph.Deleted || monograph.UserId != userId)
{
return NotFound();
}
return Ok(new { viewCount = monograph.ViewCount });
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync([FromQuery] string? deviceId, [FromRoute] string id)
{