From a87d2990b0739d4ff3834124b3dec663e61ec030 Mon Sep 17 00:00:00 2001 From: klaus Date: Fri, 19 Jun 2026 05:03:25 +0900 Subject: [PATCH] =?UTF-8?q?fix(dm):=20MainActivity=20chat=20path=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=EC=9D=84=20=EB=B3=B4=EC=A0=95?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/main/MainActivity.kt | 22 ++++++++- .../sodalive/main/MainActivitySourceTest.kt | 45 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/kr/co/vividnext/sodalive/main/MainActivitySourceTest.kt diff --git a/app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt index 250dba65..43fe80ff 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt @@ -56,6 +56,7 @@ import kr.co.vividnext.sodalive.settings.event.EventDetailActivity import kr.co.vividnext.sodalive.settings.notification.NotificationSettingsDialog import kr.co.vividnext.sodalive.user.login.LoginActivity import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelActivity +import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity import org.koin.android.ext.android.inject import java.util.Locale import kotlinx.coroutines.Job @@ -316,8 +317,10 @@ class MainActivity : BaseActivity(ActivityMainBinding::infl private fun executeBundleDeeplink(bundle: Bundle): Boolean { val deepLinkUrl = bundle.getString("deep_link") if (!deepLinkUrl.isNullOrBlank()) { - val deepLinkBundle = buildBundleFromDeepLinkUrl(deepLinkUrl) - return executeBundleRoute(deepLinkBundle ?: bundle) + val deepLinkBundle = Bundle(bundle).apply { + buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) } + } + return executeBundleRoute(deepLinkBundle) } return executeBundleRoute(bundle) @@ -339,6 +342,11 @@ class MainActivity : BaseActivity(ActivityMainBinding::infl val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull() ?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 } when { + isDmChatDeepLink(bundle) && roomId != null && roomId > 0 -> { + startActivity(DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)) + return true + } + roomId != null && roomId > 0 -> { viewModel.clickTab(MainViewModel.CurrentTab.LIVE) @@ -493,6 +501,12 @@ class MainActivity : BaseActivity(ActivityMainBinding::infl 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") @@ -620,6 +634,10 @@ class MainActivity : BaseActivity(ActivityMainBinding::infl } } + private fun isDmChatDeepLink(bundle: Bundle): Boolean { + return bundle.getString("deep_link_value") == "chat" + } + private fun clearDeferredDeepLink() { SharedPreferenceManager.marketingUtmSource = "" SharedPreferenceManager.marketingUtmMedium = "" diff --git a/app/src/test/java/kr/co/vividnext/sodalive/main/MainActivitySourceTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/main/MainActivitySourceTest.kt new file mode 100644 index 00000000..aa636ab1 --- /dev/null +++ b/app/src/test/java/kr/co/vividnext/sodalive/main/MainActivitySourceTest.kt @@ -0,0 +1,45 @@ +package kr.co.vividnext.sodalive.main + +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +class MainActivitySourceTest { + + @Test + fun `MainActivity는 deep_link를 원본 bundle에 merge하고 chat_type을 사용하지 않는다`() { + val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt").readText() + + assertTrue(source.contains("Bundle(bundle).apply")) + assertTrue(source.contains("buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }")) + assertFalse(source.contains("chat_type")) + assertFalse(source.contains("isUserCreatorChat")) + assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\"")) + } + + @Test + fun `MainActivity는 chat path deep_link 단독 payload를 DM 채팅방으로 라우팅한다`() { + val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.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(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity")) + 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(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)")) + 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() } + ?: error("Project file not found: $relativePath") + } +}