in packages/ekyc-api/src/ekyc-api/Controllers/SessionController.cs [381:432]
public async Task SubmitEyesClosedFace(string sessionId, string s3Key)
{
if (string.IsNullOrEmpty(sessionId))
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Session ID cannot be blank.");
if (string.IsNullOrEmpty(s3Key))
throw new HttpStatusException(HttpStatusCode.InternalServerError, "S3 key cannot be blank.");
// Check if the session exists
var sessionValid = await _sessionManager.SessionExistsAndIsValid(sessionId);
if (!sessionValid)
throw new HttpStatusException(HttpStatusCode.InternalServerError,
$"Session ID {sessionId} not found or has expired.");
var config = new DynamoDBOperationConfig
{
OverrideTableName = Globals.SessionTableName
};
var item = await _dbContext.LoadAsync<SessionObject>(sessionId, config);
if (item == null) throw new HttpStatusException(HttpStatusCode.InternalServerError, "Session not found.");
s3Key = sessionId + "/" + s3Key;
var imaging = new Imaging(_amazonS3, _documentChecker);
Image img;
try
{
img = await imaging.GetImageFromStorage(s3Key);
}
catch (ImageFormatException)
{
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Key provided is not a valid image.");
}
catch (Exception ex)
{
throw new HttpStatusException(HttpStatusCode.InternalServerError, ex.Message);
}
if (img == null)
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Image is not valid.");
await _livenessChecker.VerifyImageSize(img);
item.eyesClosedImageKey = s3Key;
await _dbContext.SaveAsync(item, config);
}