Skip to content

Commit

Permalink
Update AudioPlatformController.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogagliardi committed Nov 10, 2023
1 parent e8c75d1 commit 7b69eae
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions AdminWebsite/AdminWebsite/Controllers/AudioPlatformController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public async Task<IActionResult> GetAudioRecordingLinkAsync(Guid hearingId)
var requestKey = "";
if (_featureToggles.HrsEnabled())
{
var hearing = await _bookingsApiClient.GetHearingDetailsByIdV2Async(hearingId);

requestKey = GetAudioHrsFileName(hearing.ServiceId, hearing.Cases[0].Number, hearingId.ToString());
requestKey = await GetAudioHrsFileName(hearingId);
}
else
{
Expand Down Expand Up @@ -143,16 +141,22 @@ private static List<CvpForAudioFileResponse> GetCvpForAudioFileResponses(IEnumer
return response;
}

private static string GetAudioHrsFileName(string serviceId, string caseNumber, string hearingId)
private async Task<string> GetAudioHrsFileName(Guid hearingId)
{
var hearing = await _bookingsApiClient.GetHearingDetailsByIdV2Async(hearingId);

string serviceId = hearing.ServiceId;
string caseNumber = hearing.Cases[0].Number;
string hearingIdString = hearingId.ToString();

const string regex = "[^a-zA-Z0-9]";
const RegexOptions regexOptions = RegexOptions.None;
var timeout = TimeSpan.FromMilliseconds(500);

var sanitisedServiceId = Regex.Replace(serviceId, regex, "", regexOptions, timeout);
var sanitisedCaseNumber = Regex.Replace(caseNumber, regex, "", regexOptions, timeout);

return $"{sanitisedServiceId}-{sanitisedCaseNumber}-{hearingId}";
return $"{sanitisedServiceId}-{sanitisedCaseNumber}-{hearingIdString}";
}
}
}

0 comments on commit 7b69eae

Please sign in to comment.