Skip to content

Commit

Permalink
refactor: only pass necessary variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ArachisH committed Mar 31, 2024
1 parent 3658138 commit 738f23f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ private async Task WebResponseInterceptedAsync(object? sender, ResponseIntercept
{
if (e.Uri?.AbsolutePath == "/api/client/clientnative/url")
{
await HandleTicketScrapingAsync(e).ConfigureAwait(false);
await HandleTicketScrapingAsync(e.Response, e.Uri).ConfigureAwait(false);
}
}

private async Task HandleTicketScrapingAsync(ResponseInterceptedEventArgs e)
private async Task HandleTicketScrapingAsync(HttpResponseMessage message, Uri requestUri)
{
if (e.Uri!.DnsSafeHost.AsSpan().ToHotel() == HHotel.Unknown)
if (requestUri.DnsSafeHost.AsSpan().ToHotel() == HHotel.Unknown)
{
_logger.LogDebug("Failed to determine HHotel object type from '{Host}'.", e.Uri.DnsSafeHost);
_logger.LogDebug("Failed to determine HHotel object type from '{Host}'.", requestUri.DnsSafeHost);
return;
}

if (!e.IsSuccessStatusCode)
if (!message.IsSuccessStatusCode)
{
_logger.LogDebug("Status Code: {Code}", e.StatusCode);
_logger.LogDebug("Status Code: {Code}", message.StatusCode);
return;
}

string body = await e.Content.ReadAsStringAsync().ConfigureAwait(false);
string body = await message.Content.ReadAsStringAsync().ConfigureAwait(false);
if (TryExtractTicket(body, out string? ticket) && !string.IsNullOrWhiteSpace(ticket))
{
await _ticketsChannel.Writer.WriteAsync(ticket).ConfigureAwait(false);
Expand Down

0 comments on commit 738f23f

Please sign in to comment.