diff --git a/.github/workflows/release/chat-maven-build.sh b/.github/workflows/release/chat-maven-build.sh index 5587166f..be41994a 100644 --- a/.github/workflows/release/chat-maven-build.sh +++ b/.github/workflows/release/chat-maven-build.sh @@ -1,2 +1,2 @@ echo "Build Chat SDK module artifacts" -./gradlew jar \ No newline at end of file +./gradlew jar --no-configuration-cache \ No newline at end of file diff --git a/.github/workflows/release/chat-maven-publish.sh b/.github/workflows/release/chat-maven-publish.sh index 04a7637a..15db904b 100644 --- a/.github/workflows/release/chat-maven-publish.sh +++ b/.github/workflows/release/chat-maven-publish.sh @@ -1 +1 @@ -./gradlew publishToSonatype closeSonatypeStagingRepository +./gradlew publishToSonatype closeSonatypeStagingRepository --no-configuration-cache diff --git a/.github/workflows/release/pre-github-pages-publish.sh b/.github/workflows/release/pre-github-pages-publish.sh index fb521b17..0e289f10 100644 --- a/.github/workflows/release/pre-github-pages-publish.sh +++ b/.github/workflows/release/pre-github-pages-publish.sh @@ -1 +1 @@ -./gradlew :dokkaGfmMultiModule \ No newline at end of file +./gradlew :dokkaGfmMultiModule --no-configuration-cache \ No newline at end of file diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt index ba0a31b1..9d34f42c 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt @@ -58,6 +58,7 @@ import com.pubnub.chat.internal.serialization.PNDataEncoder import com.pubnub.chat.internal.timer.PlatformTimer import com.pubnub.chat.internal.timer.PlatformTimer.Companion.runPeriodically import com.pubnub.chat.internal.timer.PlatformTimer.Companion.runWithDelay +import com.pubnub.chat.internal.util.channelsUrlDecoded import com.pubnub.chat.internal.util.getPhraseToLookFor import com.pubnub.chat.internal.utils.cyrb53a import com.pubnub.chat.membership.MembershipsResponse @@ -858,7 +859,7 @@ class ChatImpl( includeMessageActions = false, includeMessageType = true ).then { pnFetchMessagesResult: PNFetchMessagesResult -> - val pnFetchMessageItems: List = pnFetchMessagesResult.channels[channelId] ?: emptyList() + val pnFetchMessageItems: List = pnFetchMessagesResult.channelsUrlDecoded[channelId] ?: emptyList() val events: Set> = pnFetchMessageItems.map { pnFetchMessageItem: PNFetchMessageItem -> EventImpl.fromDTO(chat = this, channelId = channelId, pnFetchMessageItem = pnFetchMessageItem) @@ -922,9 +923,7 @@ class ChatImpl( channelId: String, pnFetchMessagesResult: PNFetchMessagesResult ): Long { - // todo in TS there is encodeURIComponent(channelId) do we need this? - // created CLEN-2183 for PubNub SDK - val relevantLastMessage: List? = pnFetchMessagesResult.channels[channelId] + val relevantLastMessage: List? = pnFetchMessagesResult.channelsUrlDecoded[channelId] return relevantLastMessage?.firstOrNull()?.timetoken ?: 0 } diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/channel/BaseChannel.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/channel/BaseChannel.kt index f058986d..aebaea37 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/channel/BaseChannel.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/channel/BaseChannel.kt @@ -51,6 +51,7 @@ import com.pubnub.chat.internal.message.MessageImpl import com.pubnub.chat.internal.restrictions.RestrictionImpl import com.pubnub.chat.internal.serialization.PNDataEncoder import com.pubnub.chat.internal.timer.PlatformTimer.Companion.runWithDelay +import com.pubnub.chat.internal.util.channelsUrlDecoded import com.pubnub.chat.internal.util.getPhraseToLookFor import com.pubnub.chat.internal.utils.ExponentialRateLimiter import com.pubnub.chat.internal.uuidFilterString @@ -691,10 +692,10 @@ abstract class BaseChannel( includeMeta = true ).then { pnFetchMessagesResult: PNFetchMessagesResult -> HistoryResponse( - messages = pnFetchMessagesResult.channels[channelId]?.map { messageItem: PNFetchMessageItem -> + messages = pnFetchMessagesResult.channelsUrlDecoded[channelId]?.map { messageItem: PNFetchMessageItem -> messageFactory(chat, messageItem, channelId) } ?: error("Unable to read messages"), - isMore = pnFetchMessagesResult.channels[channelId]?.size == count + isMore = pnFetchMessagesResult.channelsUrlDecoded[channelId]?.size == count ) }.catch { Result.failure(PubNubException(FAILED_TO_RETRIEVE_HISTORY_DATA, it)) diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/util/Utils.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/util/Utils.kt index 171d1a5c..7b31ccd1 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/util/Utils.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/util/Utils.kt @@ -1,5 +1,7 @@ package com.pubnub.chat.internal.util +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult + internal fun getPhraseToLookFor(text: String, separator: String): String? { val lastAtIndex = text.lastIndexOf(separator) if (lastAtIndex == -1) { @@ -16,3 +18,7 @@ internal fun getPhraseToLookFor(text: String, separator: String): String? { } return splitWords.joinToString(" ") } + +expect fun urlDecode(encoded: String): String + +internal val PNFetchMessagesResult.channelsUrlDecoded get() = channels.mapKeys { urlDecode(it.key) } \ No newline at end of file diff --git a/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/integration/BaseChatIntegrationTest.kt b/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/integration/BaseChatIntegrationTest.kt index 4604cdde..34d49a15 100644 --- a/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/integration/BaseChatIntegrationTest.kt +++ b/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/integration/BaseChatIntegrationTest.kt @@ -41,7 +41,7 @@ abstract class BaseChatIntegrationTest : BaseIntegrationTest() { chatPam = ChatImpl(ChatConfiguration(), pubnubPam) channel01 = ChannelImpl( chat = chat, - id = randomString(), + id = randomString() + "!_=-@", name = randomString(), custom = mapOf(randomString() to randomString()), description = randomString(), @@ -51,7 +51,7 @@ abstract class BaseChatIntegrationTest : BaseIntegrationTest() { ) channel02 = ChannelImpl( chat = chat, - id = randomString(), + id = randomString() + "!_=-@", name = randomString(), custom = mapOf(randomString() to randomString()), description = randomString(), @@ -81,7 +81,7 @@ abstract class BaseChatIntegrationTest : BaseIntegrationTest() { ) channelPam = ChannelImpl( chat = chatPam, - id = randomString(), + id = randomString() + "!_=-@", name = randomString(), custom = mapOf(randomString() to randomString()), description = randomString(), diff --git a/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/kmp/utils/UtilsTest.kt b/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/kmp/utils/UtilsTest.kt index 4c90d27e..c0441589 100644 --- a/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/kmp/utils/UtilsTest.kt +++ b/pubnub-chat-impl/src/commonTest/kotlin/com/pubnub/kmp/utils/UtilsTest.kt @@ -43,4 +43,12 @@ class UtilsTest { val result = getPhraseToLookFor(phraseWithTwoWordsAfterHash, "#") assertEquals("$firstWord $secondWord", result) } + + @Test + fun urlDecode() { + val input = "a_-%3D%40.%21%24%23%25%26%5E%3B" + val expected = "a_-=@.!\$#%&^;" + + assertEquals(expected, com.pubnub.chat.internal.util.urlDecode(input)) + } } diff --git a/pubnub-chat-impl/src/iosMain/kotlin/com/pubnub/chat/internal/util/Utils.ios.kt b/pubnub-chat-impl/src/iosMain/kotlin/com/pubnub/chat/internal/util/Utils.ios.kt new file mode 100644 index 00000000..08ae1ffa --- /dev/null +++ b/pubnub-chat-impl/src/iosMain/kotlin/com/pubnub/chat/internal/util/Utils.ios.kt @@ -0,0 +1,5 @@ +package com.pubnub.chat.internal.util + +actual fun urlDecode(encoded: String): String { + TODO("Not yet implemented") +} \ No newline at end of file diff --git a/pubnub-chat-impl/src/jsMain/kotlin/com/pubnub/chat/internal/util/Utils.js.kt b/pubnub-chat-impl/src/jsMain/kotlin/com/pubnub/chat/internal/util/Utils.js.kt new file mode 100644 index 00000000..6c6723aa --- /dev/null +++ b/pubnub-chat-impl/src/jsMain/kotlin/com/pubnub/chat/internal/util/Utils.js.kt @@ -0,0 +1,5 @@ +package com.pubnub.chat.internal.util + +actual fun urlDecode(encoded: String): String = decodeURIComponent(encoded) + +external fun decodeURIComponent(encoded: String): String \ No newline at end of file diff --git a/pubnub-chat-impl/src/jvmMain/kotlin/com/pubnub/chat/internal/util/Utils.jvm.kt b/pubnub-chat-impl/src/jvmMain/kotlin/com/pubnub/chat/internal/util/Utils.jvm.kt new file mode 100644 index 00000000..bdea7925 --- /dev/null +++ b/pubnub-chat-impl/src/jvmMain/kotlin/com/pubnub/chat/internal/util/Utils.jvm.kt @@ -0,0 +1,5 @@ +package com.pubnub.chat.internal.util + +import java.net.URLDecoder + +actual fun urlDecode(encoded: String): String = URLDecoder.decode(encoded, Charsets.UTF_8.name()) \ No newline at end of file