fix(dm): DeepLinkActivity chat path 라우팅을 보정한다

This commit is contained in:
2026-06-19 05:03:20 +09:00
parent 9c642fb3b7
commit 5e95aa4168
2 changed files with 35 additions and 22 deletions

View File

@@ -44,7 +44,7 @@ class DeepLinkActivity : AppCompatActivity() {
}
}
if (SodaLiveApp.isAppInForeground && deepLinkExtras != null && isUserCreatorChat(deepLinkExtras)) {
if (SodaLiveApp.isAppInForeground && deepLinkExtras != null && isDmChatDeepLink(deepLinkExtras)) {
if (routeForegroundDeepLink(deepLinkExtras)) {
finish()
return
@@ -114,7 +114,6 @@ class DeepLinkActivity : AppCompatActivity() {
}
putQuery("room_id")
putQuery("chat_type")
putQuery("channel_id")
putQuery("message_id")
putQuery("audition_id")
@@ -140,7 +139,6 @@ class DeepLinkActivity : AppCompatActivity() {
}
}
copyString("chat_type")
copyString("room_id")
copyString("channel_id")
copyString("message_id")
@@ -277,7 +275,7 @@ class DeepLinkActivity : AppCompatActivity() {
val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 }
if (isUserCreatorChat(bundle) && roomId != null && roomId > 0) {
if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0) {
startActivity(DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId))
return true
}
@@ -332,8 +330,8 @@ class DeepLinkActivity : AppCompatActivity() {
return routeByDeepLinkValue(deepLinkValue = deepLinkValue, deepLinkValueId = deepLinkValueId)
}
private fun isUserCreatorChat(bundle: Bundle): Boolean {
return bundle.getString("chat_type") == "USER_CREATOR"
private fun isDmChatDeepLink(bundle: Bundle): Boolean {
return bundle.getString("deep_link_value") == "chat"
}
private fun routeByDeepLinkValue(deepLinkValue: String?, deepLinkValueId: Long?): Boolean {
@@ -442,6 +440,12 @@ class DeepLinkActivity : AppCompatActivity() {
putIfAbsent("deep_link_sub5", pathId)
}
"chat" -> {
putIfAbsent("room_id", pathId)
putIfAbsent("deep_link_value", "chat")
putIfAbsent("deep_link_sub5", pathId)
}
"content" -> {
putIfAbsent("content_id", pathId)
putIfAbsent("deep_link_value", "content")

View File

@@ -1,5 +1,6 @@
package kr.co.vividnext.sodalive.main
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.File
@@ -7,31 +8,22 @@ import java.io.File
class DeepLinkActivitySourceTest {
@Test
fun `DeepLinkActivity는 USER_CREATOR push room_id를 DM 채팅방으로 라우팅한다`() {
fun `DeepLinkActivity는 chat_type 없이 chat path만 DM 채팅방으로 라우팅한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
assertTrue(source.contains("copyString(\"chat_type\")"))
assertTrue(source.contains("private fun isUserCreatorChat(bundle: Bundle): Boolean"))
assertTrue(source.contains("bundle.getString(\"chat_type\") == \"USER_CREATOR\""))
assertFalse(source.contains("chat_type"))
assertFalse(source.contains("isUserCreatorChat"))
assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\""))
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)"))
assertTrue(source.contains("if (isUserCreatorChat(bundle) && roomId != null && roomId > 0)"))
assertTrue(source.contains("if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0)"))
}
@Test
fun `DeepLinkActivity는 URL query chat_type도 deepLinkExtras에 보존한다`() {
fun `chat path push도 LiveRoom foreground confirm broadcast보다 먼저 foreground route를 시도한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
val queryCopyStart = source.indexOf("if (data != null)")
val extrasNormalizeStart = source.indexOf("extras.getString(\"postId\")", queryCopyStart)
val queryCopySource = source.substring(queryCopyStart, extrasNormalizeStart)
assertTrue(queryCopySource.contains("putQuery(\"chat_type\")"))
assertTrue(queryCopySource.contains("putQuery(\"room_id\")"))
}
@Test
fun `USER_CREATOR push는 LiveRoom foreground confirm broadcast보다 먼저 foreground route를 시도한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
assertTrue(source.contains("SodaLiveApp.isAppInForeground && deepLinkExtras != null && isDmChatDeepLink(deepLinkExtras)"))
val dmRouteIndex = source.indexOf("routeForegroundDeepLink(deepLinkExtras)")
val liveRoomBroadcastIndex = source.indexOf("Constants.ACTION_LIVE_ROOM_DEEPLINK_CONFIRM")
@@ -41,6 +33,23 @@ class DeepLinkActivitySourceTest {
assertTrue(dmRouteIndex < liveRoomBroadcastIndex)
}
@Test
fun `DeepLinkActivity는 chat path deep_link 단독 payload를 DM 채팅방으로 라우팅한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
val chatPathIndex = source.indexOf("\"chat\" ->")
val dmRouteIndex = source.indexOf("isDmChatDeepLink(bundle) && roomId != null && roomId > 0")
val liveRouteIndex = source.indexOf("roomId != null && roomId > 0 ->")
assertTrue(chatPathIndex >= 0)
assertTrue(source.contains("putIfAbsent(\"room_id\", pathId)"))
assertTrue(source.contains("putIfAbsent(\"deep_link_value\", \"chat\")"))
assertTrue(source.contains("private fun isDmChatDeepLink(bundle: Bundle): Boolean"))
assertTrue(dmRouteIndex >= 0)
assertTrue(liveRouteIndex >= 0)
assertTrue(dmRouteIndex < liveRouteIndex)
}
private fun projectFile(relativePath: String): File {
val candidates = listOf(File(relativePath), File("../$relativePath"))
return candidates.firstOrNull { it.exists() }