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

This commit is contained in:
2026-06-19 05:03:32 +09:00
parent a87d2990b0
commit da64806d88
2 changed files with 45 additions and 8 deletions

View File

@@ -457,7 +457,9 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
val bundle = intent.getBundleExtra(Constants.EXTRA_DATA) ?: return val bundle = intent.getBundleExtra(Constants.EXTRA_DATA) ?: return
val deepLinkUrl = bundle.getString("deep_link") val deepLinkUrl = bundle.getString("deep_link")
val routeBundle = if (!deepLinkUrl.isNullOrBlank()) { val routeBundle = if (!deepLinkUrl.isNullOrBlank()) {
buildBundleFromDeepLinkUrl(deepLinkUrl) ?: bundle Bundle(bundle).apply {
buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }
}
} else { } else {
bundle bundle
} }
@@ -480,6 +482,7 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
} }
} }
putQuery("room_id")
putQuery("channel_id") putQuery("channel_id")
putQuery("message_id") putQuery("message_id")
putQuery("audition_id") putQuery("audition_id")
@@ -518,6 +521,12 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
} }
when (pathType) { when (pathType) {
"chat" -> {
putIfAbsent("room_id", pathId)
putIfAbsent("deep_link_value", "chat")
putIfAbsent("deep_link_sub5", pathId)
}
"content" -> { "content" -> {
putIfAbsent("content_id", pathId) putIfAbsent("content_id", pathId)
putIfAbsent("deep_link_value", "content") putIfAbsent("deep_link_value", "content")
@@ -565,7 +574,7 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull() val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 } ?: 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)) startActivity(DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId))
return true return true
} }
@@ -615,8 +624,8 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
return !deepLinkValue.isNullOrBlank() && routeByDeepLinkValue(deepLinkValue, deepLinkValueId) return !deepLinkValue.isNullOrBlank() && routeByDeepLinkValue(deepLinkValue, deepLinkValueId)
} }
private fun isUserCreatorChat(bundle: Bundle): Boolean { private fun isDmChatDeepLink(bundle: Bundle): Boolean {
return bundle.getString("chat_type") == "USER_CREATOR" return bundle.getString("deep_link_value") == "chat"
} }
private fun routeByDeepLinkValue(deepLinkValue: String, deepLinkValueId: Long?): Boolean { private fun routeByDeepLinkValue(deepLinkValue: String, deepLinkValueId: Long?): Boolean {

View File

@@ -1,5 +1,6 @@
package kr.co.vividnext.sodalive.v2.main package kr.co.vividnext.sodalive.v2.main
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
@@ -7,15 +8,42 @@ import java.io.File
class MainV2ActivitySourceTest { class MainV2ActivitySourceTest {
@Test @Test
fun `MainV2Activity는 USER_CREATOR push room_id를 DM 채팅방으로 라우팅한다`() { fun `MainV2Activity는 chat_type 없이 chat path만 DM 채팅방으로 라우팅한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/v2/main/MainV2Activity.kt").readText() val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/v2/main/MainV2Activity.kt").readText()
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity")) assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
assertTrue(source.contains("private fun isUserCreatorChat(bundle: Bundle): Boolean")) assertFalse(source.contains("chat_type"))
assertTrue(source.contains("bundle.getString(\"chat_type\") == \"USER_CREATOR\"")) assertFalse(source.contains("isUserCreatorChat"))
assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\""))
assertTrue(source.contains("val roomId = bundle.getString(\"room_id\")?.toLongOrNull()")) assertTrue(source.contains("val roomId = bundle.getString(\"room_id\")?.toLongOrNull()"))
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)")) 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 `MainV2Activity는 deep_link를 원본 bundle에 merge한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/v2/main/MainV2Activity.kt").readText()
assertTrue(source.contains("Bundle(bundle).apply"))
assertTrue(source.contains("buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }"))
assertTrue(source.contains("putQuery(\"room_id\")"))
}
@Test
fun `MainV2Activity는 chat path deep_link 단독 payload를 DM 채팅방으로 라우팅한다`() {
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/v2/main/MainV2Activity.kt").readText()
val chatPathIndex = source.indexOf("\"chat\" ->")
val dmRouteIndex = source.indexOf("isDmChatDeepLink(bundle) && roomId != null && roomId > 0")
val firstFallbackIndex = source.indexOf("channelId != null && channelId > 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(firstFallbackIndex >= 0)
assertTrue(dmRouteIndex < firstFallbackIndex)
} }
private fun projectFile(relativePath: String): File { private fun projectFile(relativePath: String): File {