From 7ac58715d6cb981d12f4ff43bedf9f2b7388d68a Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Tue, 2 Apr 2024 03:29:36 -0700 Subject: [PATCH] feat: support for only room-code --- .../main/java/live/hms/app2/ui/home/HomeFragment.kt | 5 +++++ app/src/main/java/live/hms/app2/util/Constants.kt | 1 + .../main/java/live/hms/app2/util/MeetingUrlUtils.kt | 12 +++++------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt b/app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt index 660e1ed40..cf138b62a 100644 --- a/app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt +++ b/app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt @@ -21,6 +21,7 @@ import live.hms.app2.R import live.hms.app2.databinding.FragmentHomeBinding import live.hms.app2.util.REGEX_MEETING_URL_CODE import live.hms.app2.util.REGEX_PREVIEW_URL_CODE +import live.hms.app2.util.REGEX_ROOM_CODE import live.hms.app2.util.REGEX_STREAMING_MEETING_URL_ROOM_CODE import live.hms.app2.util.getInitEndpointEnvironment import live.hms.app2.util.isValidMeetingUrl @@ -139,6 +140,10 @@ class HomeFragment : Fragment() { val groups = REGEX_PREVIEW_URL_CODE.findAll(url).toList()[0].groupValues groups[2] } + REGEX_ROOM_CODE.matches(url) -> { + val groups = REGEX_ROOM_CODE.findAll(url).toList()[0].groupValues + groups[0] + } else -> null } } diff --git a/app/src/main/java/live/hms/app2/util/Constants.kt b/app/src/main/java/live/hms/app2/util/Constants.kt index db2def3f6..b396c1d44 100644 --- a/app/src/main/java/live/hms/app2/util/Constants.kt +++ b/app/src/main/java/live/hms/app2/util/Constants.kt @@ -4,6 +4,7 @@ const val ENV_PROD = "prod-init" const val ENV_QA = "qa-init" val REGEX_MEETING_URL_CODE = Regex("https?://(.*.100ms.live)/meeting/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?") +val REGEX_ROOM_CODE = Regex("[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+") val REGEX_PREVIEW_URL_CODE = Regex("https?://(.*.100ms.live)/preview/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?") val REGEX_STREAMING_MEETING_URL_ROOM_CODE = Regex("https?://(.*.100ms.live)/streaming/meeting/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?") val REGEX_MEETING_URL_ROOM_ID = Regex("https?://(.*.100ms.live)/meeting/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?") diff --git a/app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt b/app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt index a7cb55a1e..57067c060 100644 --- a/app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt +++ b/app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt @@ -2,18 +2,16 @@ package live.hms.app2.util fun String.isValidMeetingUrl(): Boolean = this.matches(REGEX_MEETING_URL_ROOM_ID) || this.matches(REGEX_MEETING_URL_CODE) || this.matches(REGEX_PREVIEW_URL_CODE) || this.matches( - REGEX_STREAMING_MEETING_URL_ROOM_CODE) + REGEX_STREAMING_MEETING_URL_ROOM_CODE) || this.matches(REGEX_ROOM_CODE) fun String.getTokenEndpointEnvironment(): String = when { - this.contains("prod2.100ms.live") -> "prod-in" - this.contains(".app.100ms.live") -> "prod-in" - else -> "qa-in2" + this.contains(".qa-app.100ms.live") -> ENV_QA + else -> ENV_PROD } fun String.getInitEndpointEnvironment(): String = when { - this.contains("prod2.100ms.live") -> ENV_PROD - this.contains(".app.100ms.live") -> ENV_PROD - else -> ENV_QA + this.contains(".qa-app.100ms.live") -> ENV_QA + else -> ENV_PROD } fun String.toUniqueRoomSpecifier(): String {