@@ -1,6 +1,6 @@
|
||||
using Refit;
|
||||
using Models.Requests;
|
||||
using CvMatcher.Models.Responses;
|
||||
using Models.Requests;
|
||||
using Refit;
|
||||
|
||||
namespace Api.Clients.Api.Contracts;
|
||||
|
||||
@@ -8,8 +8,8 @@ public interface ICvMatcherApi
|
||||
{
|
||||
[Multipart]
|
||||
[Post("/api/cv/upload")]
|
||||
Task<CvUploadResponse> Upload([AliasAs("cv")] StreamPart cv, [AliasAs("gdprConsent")] bool gdprConsent);
|
||||
Task<CvUploadResponse> Upload([AliasAs("file")] StreamPart file, CancellationToken ct);
|
||||
|
||||
[Post("/api/cv/match-job")]
|
||||
Task<JobMatchResponse> MatchJob([Body] JobMatchRequest request);
|
||||
Task<JobMatchResponse> MatchJob([Body] JobMatchRequest request, CancellationToken ct);
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ public sealed class CvMatcherController : ControllerBase
|
||||
[FromForm] UploadCvRequest request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
if (request.Cv is null)
|
||||
if (request.File is null)
|
||||
{
|
||||
return BadRequest(new { error = "Missing CV PDF." });
|
||||
}
|
||||
|
||||
var cv = request.Cv;
|
||||
var cv = request.File;
|
||||
var gdprConsent = request.GdprConsent;
|
||||
|
||||
try
|
||||
@@ -65,12 +65,14 @@ public sealed class CvMatcherController : ControllerBase
|
||||
return BadRequest(new { error = "Captcha verification failed." });
|
||||
}
|
||||
|
||||
if (!gdprConsent) throw new InvalidOperationException("GDPR consent is required.");
|
||||
|
||||
_logger.LogInformation("Proxying CV upload to cv-matcher-api. FileName={FileName}, Size={SizeBytes}, GdprConsent={GdprConsent}",
|
||||
cv.FileName, cv.Length, gdprConsent);
|
||||
|
||||
var stream = cv.OpenReadStream();
|
||||
var part = new Refit.StreamPart(stream, cv.FileName, "application/pdf");
|
||||
var res = await _cvApi.Upload(part, gdprConsent);
|
||||
var res = await _cvApi.Upload(part, ct);
|
||||
return Ok(res);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
@@ -114,7 +116,7 @@ public sealed class CvMatcherController : ControllerBase
|
||||
request.CvDocumentId,
|
||||
!string.IsNullOrWhiteSpace(request.JobUrl),
|
||||
!string.IsNullOrWhiteSpace(request.JobDescription));
|
||||
var res = await _cvApi.MatchJob(request);
|
||||
var res = await _cvApi.MatchJob(request, ct);
|
||||
return Ok(res);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
|
||||
Reference in New Issue
Block a user