fix(dm): DeepLinkActivity chat path 라우팅을 보정한다
This commit is contained in:
@@ -44,7 +44,7 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SodaLiveApp.isAppInForeground && deepLinkExtras != null && isUserCreatorChat(deepLinkExtras)) {
|
if (SodaLiveApp.isAppInForeground && deepLinkExtras != null && isDmChatDeepLink(deepLinkExtras)) {
|
||||||
if (routeForegroundDeepLink(deepLinkExtras)) {
|
if (routeForegroundDeepLink(deepLinkExtras)) {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
@@ -114,7 +114,6 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
putQuery("room_id")
|
putQuery("room_id")
|
||||||
putQuery("chat_type")
|
|
||||||
putQuery("channel_id")
|
putQuery("channel_id")
|
||||||
putQuery("message_id")
|
putQuery("message_id")
|
||||||
putQuery("audition_id")
|
putQuery("audition_id")
|
||||||
@@ -140,7 +139,6 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyString("chat_type")
|
|
||||||
copyString("room_id")
|
copyString("room_id")
|
||||||
copyString("channel_id")
|
copyString("channel_id")
|
||||||
copyString("message_id")
|
copyString("message_id")
|
||||||
@@ -277,7 +275,7 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
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
|
||||||
}
|
}
|
||||||
@@ -332,8 +330,8 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
return routeByDeepLinkValue(deepLinkValue = deepLinkValue, deepLinkValueId = deepLinkValueId)
|
return routeByDeepLinkValue(deepLinkValue = deepLinkValue, deepLinkValueId = 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 {
|
||||||
@@ -442,6 +440,12 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||||||
putIfAbsent("deep_link_sub5", pathId)
|
putIfAbsent("deep_link_sub5", pathId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"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")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package kr.co.vividnext.sodalive.main
|
package kr.co.vividnext.sodalive.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,31 +8,22 @@ import java.io.File
|
|||||||
class DeepLinkActivitySourceTest {
|
class DeepLinkActivitySourceTest {
|
||||||
|
|
||||||
@Test
|
@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()
|
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("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
|
||||||
assertTrue(source.contains("copyString(\"chat_type\")"))
|
assertFalse(source.contains("chat_type"))
|
||||||
assertTrue(source.contains("private fun isUserCreatorChat(bundle: Bundle): Boolean"))
|
assertFalse(source.contains("isUserCreatorChat"))
|
||||||
assertTrue(source.contains("bundle.getString(\"chat_type\") == \"USER_CREATOR\""))
|
assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\""))
|
||||||
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
|
@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 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(source.contains("SodaLiveApp.isAppInForeground && deepLinkExtras != null && isDmChatDeepLink(deepLinkExtras)"))
|
||||||
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()
|
|
||||||
|
|
||||||
val dmRouteIndex = source.indexOf("routeForegroundDeepLink(deepLinkExtras)")
|
val dmRouteIndex = source.indexOf("routeForegroundDeepLink(deepLinkExtras)")
|
||||||
val liveRoomBroadcastIndex = source.indexOf("Constants.ACTION_LIVE_ROOM_DEEPLINK_CONFIRM")
|
val liveRoomBroadcastIndex = source.indexOf("Constants.ACTION_LIVE_ROOM_DEEPLINK_CONFIRM")
|
||||||
@@ -41,6 +33,23 @@ class DeepLinkActivitySourceTest {
|
|||||||
assertTrue(dmRouteIndex < liveRoomBroadcastIndex)
|
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 {
|
private fun projectFile(relativePath: String): File {
|
||||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||||
return candidates.firstOrNull { it.exists() }
|
return candidates.firstOrNull { it.exists() }
|
||||||
|
|||||||
Reference in New Issue
Block a user