feat/Update_Controllers_to_Allow_for_Premium_Membership

This commit is contained in:
cesnimda
2026-08-03 09:17:28 +02:00
parent de937d25dc
commit c3f4a57195
187 changed files with 26062 additions and 991 deletions
@@ -136,6 +136,7 @@ public sealed partial class ProfileCvController : ControllerBase
private sealed record ClassifiedCvBlock(int Index, string OriginalBlock, string SectionName, string Content, CvBlockClassificationResult? Classification);
[HttpPost("upload")]
[Authorize(Policy = ProEntitlement.Policy)]
[RequestSizeLimit(MaxFileSizeBytes)]
public async Task<IActionResult> Upload([FromForm] IFormFile file)
{
@@ -206,11 +207,9 @@ public sealed partial class ProfileCvController : ControllerBase
var user = await _users.GetUserAsync(User);
if (user is null) return Unauthorized();
var runs = await _db.CvExtractionRuns
var runsQuery = _db.CvExtractionRuns
.AsNoTracking()
.Where(x => x.OwnerUserId == user.Id)
.OrderByDescending(x => x.StartedAtUtc)
.Take(10)
.Select(x => new CvExtractionRunListItem(
x.Id,
x.Trigger,
@@ -222,8 +221,10 @@ public sealed partial class ProfileCvController : ControllerBase
x.ParserVersion,
x.NormalizerVersion,
x.LlmPromptVersion,
x.ErrorMessage))
.ToListAsync(HttpContext.RequestAborted);
x.ErrorMessage));
var runs = _db.Database.IsSqlite()
? (await runsQuery.ToListAsync(HttpContext.RequestAborted)).OrderByDescending(x => x.StartedAtUtc).Take(10).ToList()
: await runsQuery.OrderByDescending(x => x.StartedAtUtc).Take(10).ToListAsync(HttpContext.RequestAborted);
return Ok(runs);
}
@@ -294,15 +295,16 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("reprocess")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<IActionResult> Reprocess()
{
var user = await _users.GetUserAsync(User);
if (user is null) return Unauthorized();
var artifact = await _db.CvUploadArtifacts
.AsNoTracking()
.OrderByDescending(x => x.UploadedAtUtc)
.FirstOrDefaultAsync(x => x.OwnerUserId == user.Id, HttpContext.RequestAborted);
var artifactQuery = _db.CvUploadArtifacts.AsNoTracking().Where(x => x.OwnerUserId == user.Id);
var artifact = _db.Database.IsSqlite()
? (await artifactQuery.ToListAsync(HttpContext.RequestAborted)).MaxBy(x => x.UploadedAtUtc)
: await artifactQuery.OrderByDescending(x => x.UploadedAtUtc).FirstOrDefaultAsync(HttpContext.RequestAborted);
if (artifact is null) return BadRequest("Upload a CV before reprocessing it.");
if (string.IsNullOrWhiteSpace(artifact.StoragePath) || !System.IO.File.Exists(artifact.StoragePath))
@@ -316,6 +318,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("rebuild")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<IActionResult> Rebuild()
{
var user = await _users.GetUserAsync(User);
@@ -328,6 +331,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("rewrite-section")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<IActionResult> RewriteSection([FromBody] RewriteSectionRequest request)
{
var user = await _users.GetUserAsync(User);
@@ -431,6 +435,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("rewrite-preview")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<ActionResult<ProfileCvPreviewDto>> BuildRewritePreview([FromBody] RewriteSectionRequest request)
{
var user = await _users.GetUserAsync(User);
@@ -473,6 +478,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("export-pdf")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<IActionResult> ExportProfileCvPdf([FromBody] RewriteSectionRequest request, CancellationToken cancellationToken)
{
var previewResult = await BuildRewritePreview(request);
@@ -492,6 +498,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("parse")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<ActionResult<object>> Parse([FromBody] ParseCvRequest? request)
{
var user = await _users.GetUserAsync(User);
@@ -512,6 +519,7 @@ public sealed partial class ProfileCvController : ControllerBase
}
[HttpPost("improve")]
[Authorize(Policy = ProEntitlement.Policy)]
public async Task<IActionResult> Improve()
{
var user = await _users.GetUserAsync(User);