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..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 @@ -20,17 +20,14 @@ 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. * - * 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. */ @@ -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(