Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for only room-code #680

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -139,6 +140,10 @@ class HomeFragment : Fragment() {
val groups = REGEX_PREVIEW_URL_CODE.findAll(url).toList()[0].groupValues
groups[groups.size - 1]
}
REGEX_ROOM_CODE.matches(url) -> {
val groups = REGEX_ROOM_CODE.findAll(url).toList()[0].groupValues
groups[0]
}
else -> null
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/live/hms/app2/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)|(preview))/([a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+)/?")
val REGEX_MEETING_URL_ROOM_ID = Regex("https?://(.*.100ms.live)/((meeting)|(preview))/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?")
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/java/live/hms/app2/util/MeetingUrlUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 getBeamBotJoiningUrl(meetingUrl: String, roomId: String, beamBotUser: String): String {
Expand Down