From 1738cd8e9d8573930ab69193ea50cc2b7580b9e7 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Tue, 10 Mar 2026 20:06:08 +0100 Subject: [PATCH 1/2] Fix wrong message type for commands in getMessageType() Co-Authored-By: Claude --- .../chat/android/client/utils/internal/MessageUtils.kt | 5 +---- .../chat/android/client/utils/internal/MessageUtilsTest.kt | 7 ------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt index f0791349f23..01bcccb6ea1 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt @@ -20,9 +20,6 @@ import io.getstream.chat.android.client.extensions.internal.hasPendingAttachment import io.getstream.chat.android.core.internal.InternalStreamChatApi import io.getstream.chat.android.models.Message import io.getstream.chat.android.models.MessageType -import java.util.regex.Pattern - -private val COMMAND_PATTERN = Pattern.compile("^/[a-z]*$") /** * Updates the type of the [Message] based on its content. @@ -39,7 +36,7 @@ public fun getMessageType(message: Message): String { val hasAttachments = message.attachments.isNotEmpty() val hasAttachmentsToUpload = message.hasPendingAttachments() - return if (COMMAND_PATTERN.matcher(message.text).find() || (hasAttachments && hasAttachmentsToUpload)) { + return if (hasAttachments && hasAttachmentsToUpload) { MessageType.EPHEMERAL } else if (message.type == MessageType.SYSTEM) { MessageType.SYSTEM diff --git a/stream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt b/stream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt index 596fdd3647c..6eda992e991 100644 --- a/stream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt +++ b/stream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt @@ -24,13 +24,6 @@ import org.junit.jupiter.api.Test internal class MessageUtilsTest { - @Test - fun testCommandMessage() { - val message = Message(text = "/command") - val updatedMessageType = getMessageType(message) - updatedMessageType `should be equal to` MessageType.EPHEMERAL - } - @Test fun testMessageWithAttachmentsInUploadStateIdle() { val message = Message( From 4fe2043d1ae0d57e2060123bbaa271dcac8a0692 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Tue, 10 Mar 2026 20:30:18 +0100 Subject: [PATCH 2/2] Fix KDoc --- .../chat/android/client/utils/internal/MessageUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt index 01bcccb6ea1..2e9b6baf803 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt @@ -24,10 +24,10 @@ import io.getstream.chat.android.models.MessageType /** * Updates the type of the [Message] based on its content. * - * If the message contains a command or has attachments to upload, the type will be [MessageType.EPHEMERAL]. + * If the message has attachments to upload, the type will be [MessageType.EPHEMERAL] (local-only - after the + * attachments are uploaded, the type is changed to [MessageType.REGULAR]). * If the message is a system message, the type will be [MessageType.SYSTEM]. - * Otherwise, the type will be [MessageType.REGULAR], as we cannot send messages which are not regular, ephemeral, or - * system. + * Otherwise, the type will be [MessageType.REGULAR], as we cannot send messages which are not regular or system. * * @param message The message to update. */