From 442999688842e21bb8930382a08ffd0dde8eae8c Mon Sep 17 00:00:00 2001 From: colin-lamed <9568290+colin-lamed@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:41:00 +0100 Subject: [PATCH] BDOG-1512 Make deviceId extraction logic more readable --- .../uk/gov/hmrc/play/http/HeaderCarrierConverter.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/http-verbs-common/src/main/scala/uk/gov/hmrc/play/http/HeaderCarrierConverter.scala b/http-verbs-common/src/main/scala/uk/gov/hmrc/play/http/HeaderCarrierConverter.scala index fa23bf0a..486ec65e 100644 --- a/http-verbs-common/src/main/scala/uk/gov/hmrc/play/http/HeaderCarrierConverter.scala +++ b/http-verbs-common/src/main/scala/uk/gov/hmrc/play/http/HeaderCarrierConverter.scala @@ -94,10 +94,8 @@ trait HeaderCarrierConverter { trueClientPort = headers.get(HeaderNames.trueClientPort), gaToken = headers.get(HeaderNames.googleAnalyticTokenId), gaUserId = headers.get(HeaderNames.googleAnalyticUserId), - deviceID = session.fold(headers.get(HeaderNames.deviceID))(_ => - cookies.get(CookieNames.deviceID).map(_.value) - .fold[Option[String]](headers.get(HeaderNames.deviceID))(Some(_)) - ), + deviceID = session.flatMap(_ => cookies.get(CookieNames.deviceID).map(_.value)) + .orElse(headers.get(HeaderNames.deviceID)), akamaiReputation = headers.get(HeaderNames.akamaiReputation).map(AkamaiReputation), otherHeaders = otherHeaders(headers, request) )