mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 13:57:10 +09:00
DROID-3506 Deep link | Fix | Fix handling deep link with invite (#2205)
This commit is contained in:
parent
d5626166fe
commit
5a505bf935
2 changed files with 20 additions and 8 deletions
|
@ -84,11 +84,21 @@ object DefaultDeepLinkResolver : DeepLinkResolver {
|
|||
val space = uri.getQueryParameter(SPACE_ID_PARAM)?.takeIf { it.isNotEmpty() }
|
||||
?: return DeepLinkResolver.Action.Unknown // Ensure spaceId is required
|
||||
|
||||
val key = uri.getQueryParameter(DefaultSpaceInviteResolver.FILE_KEY_KEY)
|
||||
val cid = uri.getQueryParameter(DefaultSpaceInviteResolver.CONTENT_ID_KEY)
|
||||
|
||||
return if (obj != null) {
|
||||
DeepLinkResolver.Action.DeepLinkToObject(
|
||||
obj = obj,
|
||||
space = SpaceId(space),
|
||||
invite = parseInvite(uri)
|
||||
invite = if (!key.isNullOrEmpty() && !cid.isNullOrEmpty()) {
|
||||
DeepLinkResolver.Action.DeepLinkToObject.Invite(
|
||||
key = key,
|
||||
cid = cid
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
} else {
|
||||
DeepLinkResolver.Action.Unknown
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.key
|
|||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.misc.DeepLinkResolver
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlin.test.assertIs
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -55,20 +56,21 @@ class DefaultDeepLinkResolverTest {
|
|||
|
||||
@Test
|
||||
fun `resolve link to object deep link with invite`() {
|
||||
// Given
|
||||
|
||||
val obj = MockDataFactory.randomUuid()
|
||||
val obj = "bafyreieaishyk22ik3v4m32zuy3uy2tmiv77fxogtjfv6adqfha4o3k3g4"
|
||||
|
||||
val space = MockDataFactory.randomUuid()
|
||||
val space = "bafyreid5qfqm4jsujeuebi3c4oca3hfezhoqazmm6jeg6b7rakcxj5jdse.hsqlz8alp6p8"
|
||||
|
||||
val cid = MockDataFactory.randomUuid()
|
||||
val cid = "bafybeibwcymz6tpq7jydnhwrlouwazzjwu4idoq6sreqold47ovdb7pin4"
|
||||
|
||||
val encryption = MockDataFactory.randomUuid()
|
||||
val encryption = "8wujCkLqv6PiDGHA6iVWRkHpz5y4wF7iHLcrgkSPJqhb"
|
||||
|
||||
val link = "anytype://object?objectId=$obj&spaceId=$space&cid=$cid&key=$encryption&route=Web"
|
||||
|
||||
val deeplink = "anytype://object?objectId=$obj&spaceId=$space&inviteId=$cid#$encryption"
|
||||
|
||||
// When
|
||||
val result = deepLinkResolver.resolve(deeplink)
|
||||
val result = deepLinkResolver.resolve(link)
|
||||
|
||||
|
||||
// Then
|
||||
assertEquals(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue