From ccb1b8b598102649a216ad629d66467c5a2a6710 Mon Sep 17 00:00:00 2001
From: Yamil Medina <yamilmedina@users.noreply.github.com>
Date: Tue, 5 Nov 2024 05:36:41 -0300
Subject: [PATCH] chore: apply QR profile feature flag to deeplink processing
 (WPB-11921) (#3581)

---
 .../util/deeplink/DeepLinkProcessor.kt        | 28 ++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/app/src/main/kotlin/com/wire/android/util/deeplink/DeepLinkProcessor.kt b/app/src/main/kotlin/com/wire/android/util/deeplink/DeepLinkProcessor.kt
index 327e3037992..d23e7c38a08 100644
--- a/app/src/main/kotlin/com/wire/android/util/deeplink/DeepLinkProcessor.kt
+++ b/app/src/main/kotlin/com/wire/android/util/deeplink/DeepLinkProcessor.kt
@@ -25,6 +25,7 @@ import com.wire.android.feature.AccountSwitchUseCase
 import com.wire.android.feature.SwitchAccountParam
 import com.wire.android.feature.SwitchAccountResult
 import com.wire.android.util.EMPTY
+import com.wire.android.util.debug.FeatureVisibilityFlags
 import com.wire.kalium.logic.CoreLogic
 import com.wire.kalium.logic.data.auth.AccountInfo
 import com.wire.kalium.logic.data.id.ConversationId
@@ -147,22 +148,35 @@ class DeepLinkProcessor @Inject constructor(
         }
     }
 
+    /**
+     * TODO(Rewrite)
+     * Wait for definitions of Deeplink processing RFC (https://wearezeta.atlassian.net/wiki/x/AgAsWg)
+     *
+     * REF: WPB-10532
+     */
     private fun getConnectingUserProfile(uri: Uri, switchedAccount: Boolean, accountInfo: AccountInfo.Valid): DeepLinkResult {
-        return uri.lastPathSegment?.toDefaultQualifiedId(accountInfo.userId.domain)?.let {
-            DeepLinkResult.OpenOtherUserProfile(it, switchedAccount)
-        } ?: DeepLinkResult.Unknown
+        return if (FeatureVisibilityFlags.QRCodeEnabled) {
+            // TODO: Wait for definitions of Deeplink processing RFC (https://wearezeta.atlassian.net/wiki/x/AgAsWg)
+            // TODO: define format of deeplink wire://user/domain/user-id
+            uri.lastPathSegment?.toDefaultQualifiedId(accountInfo.userId.domain)?.let {
+                DeepLinkResult.OpenOtherUserProfile(it, switchedAccount)
+            }
+            DeepLinkResult.Unknown
+        } else {
+            DeepLinkResult.Unknown
+        }
     }
 
     /**
-     * Currently the DeepLinks sent from web are not qualified.
-     * This is way to default to the current account domain as a best effort.
+     * TODO(Rewrite)
+     * Wait for definitions of Deeplink processing RFC (https://wearezeta.atlassian.net/wiki/x/AgAsWg)
+     * i.e. Define format of deeplink wire://user/domain/user-id
      *
-     * TODO: replace and remove this with String.toQualifiedID() when web sends qualified id.
      * REF: WPB-10532
      */
     private fun String.toDefaultQualifiedId(currentUserDomain: String?): QualifiedID {
         val domain = currentUserDomain ?: "wire.com"
-        // This lowercase is important, since web/iOS is sending/handling this as uppercase.
+        // TODO. This lowercase is important, since web/iOS is sending/handling this as uppercase!!
         return QualifiedID(this.lowercase(), domain)
     }