From 5e95aa4168f6391c88ead7752d9c37c9cc439489 Mon Sep 17 00:00:00 2001 From: klaus Date: Fri, 19 Jun 2026 05:03:20 +0900 Subject: [PATCH] =?UTF-8?q?fix(dm):=20DeepLinkActivity=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 --- .../sodalive/main/DeepLinkActivity.kt | 16 +++++--- .../main/DeepLinkActivitySourceTest.kt | 41 +++++++++++-------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt index 4fd95956..a66877fb 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt @@ -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") diff --git a/app/src/test/java/kr/co/vividnext/sodalive/main/DeepLinkActivitySourceTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/main/DeepLinkActivitySourceTest.kt index 34a90bfb..f6fa82fc 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/main/DeepLinkActivitySourceTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/main/DeepLinkActivitySourceTest.kt @@ -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() }