diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt index 553c36a9f4..fb94d61c0b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt @@ -200,7 +200,7 @@ data class Event( fun Event.isTextMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.type) { + && when (getClearContent()?.toModel()?.msgType) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_NOTICE -> true @@ -210,7 +210,7 @@ fun Event.isTextMessage(): Boolean { fun Event.isImageMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.type) { + && when (getClearContent()?.toModel()?.msgType) { MessageType.MSGTYPE_IMAGE -> true else -> false } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageAudioContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageAudioContent.kt index 624d827de1..e9c6c71882 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageAudioContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageAudioContent.kt @@ -25,9 +25,9 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo @JsonClass(generateAdapter = true) data class MessageAudioContent( /** - * Not documented + * Required. Must be 'm.audio'. */ - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, /** * Required. A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'. @@ -40,7 +40,7 @@ data class MessageAudioContent( @Json(name = "info") val audioInfo: AudioInfo? = null, /** - * Required. Required if the file is not encrypted. The URL (typically MXC URI) to the audio clip. + * Required if the file is not encrypted. The URL (typically MXC URI) to the audio clip. */ @Json(name = "url") override val url: String? = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt index c0adfa4c36..bc5228e5e8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt @@ -20,8 +20,7 @@ import im.vector.matrix.android.api.session.events.model.Content import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent interface MessageContent { - // TODO Rename to msgType - val type: String + val msgType: String val body: String val relatesTo: RelationDefaultContent? val newContent: Content? diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageDefaultContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageDefaultContent.kt index 705dbf5d85..7a5c7e2cd5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageDefaultContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageDefaultContent.kt @@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC @JsonClass(generateAdapter = true) data class MessageDefaultContent( - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, @Json(name = "body") override val body: String, @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEmoteContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEmoteContent.kt index ec340659a2..e7106a9755 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEmoteContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEmoteContent.kt @@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC @JsonClass(generateAdapter = true) data class MessageEmoteContent( - @Json(name = "msgtype") override val type: String, + /** + * Required. Must be 'm.emote'. + */ + @Json(name = "msgtype") override val msgType: String, + + /** + * Required. The emote action to perform. + */ @Json(name = "body") override val body: String, + + /** + * The format used in the formatted_body. Currently only org.matrix.custom.html is supported. + */ @Json(name = "format") val format: String? = null, + + /** + * The formatted version of the body. This is required if format is specified. + */ @Json(name = "formatted_body") val formattedBody: String? = null, + @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null ) : MessageContent diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEncryptedContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEncryptedContent.kt index 110b9c68f0..1d1d01c09c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEncryptedContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageEncryptedContent.kt @@ -23,10 +23,13 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo */ interface MessageEncryptedContent : MessageContent { /** - * Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image. + * Required if the file is unencrypted. The URL (typically MXC URI) to the image. */ val url: String? + /** + * Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption. + */ val encryptedFileInfo: EncryptedFileInfo? } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageFileContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageFileContent.kt index ac70f5bf74..7c635a401d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageFileContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageFileContent.kt @@ -26,9 +26,9 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo @JsonClass(generateAdapter = true) data class MessageFileContent( /** - * Not documented + * Required. Must be 'm.file'. */ - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, /** * Required. A human-readable description of the file. This is recommended to be the filename of the original upload. @@ -46,13 +46,16 @@ data class MessageFileContent( @Json(name = "info") val info: FileInfo? = null, /** - * Required. Required if the file is unencrypted. The URL (typically MXC URI) to the file. + * Required if the file is unencrypted. The URL (typically MXC URI) to the file. */ @Json(name = "url") override val url: String? = null, @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null, + /** + * Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption. + */ @Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null ) : MessageEncryptedContent { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageImageContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageImageContent.kt index fbac261802..f50a108947 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageImageContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageImageContent.kt @@ -27,7 +27,7 @@ data class MessageImageContent( /** * Required. Must be 'm.image'. */ - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, /** * Required. A textual representation of the image. This could be the alt text of the image, the filename of the image, @@ -41,7 +41,7 @@ data class MessageImageContent( @Json(name = "info") override val info: ImageInfo? = null, /** - * Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image. + * Required if the file is unencrypted. The URL (typically MXC URI) to the image. */ @Json(name = "url") override val url: String? = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageLocationContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageLocationContent.kt index 15c746fd38..02ba9eae6e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageLocationContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageLocationContent.kt @@ -24,9 +24,9 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC @JsonClass(generateAdapter = true) data class MessageLocationContent( /** - * Not documented + * Required. Must be 'm.location'. */ - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, /** * Required. A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'. diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageNoticeContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageNoticeContent.kt index 9a4fea1060..e08e07e9da 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageNoticeContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageNoticeContent.kt @@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC @JsonClass(generateAdapter = true) data class MessageNoticeContent( - @Json(name = "msgtype") override val type: String, + /** + * Required. Must be 'm.notice'. + */ + @Json(name = "msgtype") override val msgType: String, + + /** + * Required. The notice text to send. + */ @Json(name = "body") override val body: String, + + /** + * The format used in the formatted_body. Currently only org.matrix.custom.html is supported. + */ @Json(name = "format") val format: String? = null, + + /** + * The formatted version of the body. This is required if format is specified. + */ @Json(name = "formatted_body") val formattedBody: String? = null, + @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null ) : MessageContent diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageStickerContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageStickerContent.kt index d1b4a5c3cb..9198537bff 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageStickerContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageStickerContent.kt @@ -12,7 +12,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package im.vector.matrix.android.api.session.room.model.message @@ -28,7 +27,7 @@ data class MessageStickerContent( /** * Set in local, not from server */ - override val type: String = MessageType.MSGTYPE_STICKER_LOCAL, + override val msgType: String = MessageType.MSGTYPE_STICKER_LOCAL, /** * Required. A textual representation of the image. This could be the alt text of the image, the filename of the image, @@ -42,7 +41,7 @@ data class MessageStickerContent( @Json(name = "info") override val info: ImageInfo? = null, /** - * Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image. + * Required if the file is unencrypted. The URL (typically MXC URI) to the image. */ @Json(name = "url") override val url: String? = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageTextContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageTextContent.kt index 001b9ff0dd..cc5bb1f774 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageTextContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageTextContent.kt @@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC @JsonClass(generateAdapter = true) data class MessageTextContent( - @Json(name = "msgtype") override val type: String, + /** + * Required. Must be 'm.text'. + */ + @Json(name = "msgtype") override val msgType: String, + + /** + * Required. The body of the message. + */ @Json(name = "body") override val body: String, + + /** + * The format used in the formatted_body. Currently only org.matrix.custom.html is supported. + */ @Json(name = "format") val format: String? = null, + + /** + * The formatted version of the body. This is required if format is specified. + */ @Json(name = "formatted_body") val formattedBody: String? = null, + @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null ) : MessageContent diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationRequestContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationRequestContent.kt index c8026e2f26..2ef4979f9d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationRequestContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationRequestContent.kt @@ -24,7 +24,7 @@ import im.vector.matrix.android.internal.crypto.verification.VerificationInfoReq @JsonClass(generateAdapter = true) data class MessageVerificationRequestContent( - @Json(name = "msgtype") override val type: String = MessageType.MSGTYPE_VERIFICATION_REQUEST, + @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST, @Json(name = "body") override val body: String, @Json(name = "from_device") override val fromDevice: String?, @Json(name = "methods") override val methods: List, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVideoContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVideoContent.kt index 1c84b3e72e..4cf03a5ffd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVideoContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVideoContent.kt @@ -27,7 +27,7 @@ data class MessageVideoContent( /** * Required. Must be 'm.video'. */ - @Json(name = "msgtype") override val type: String, + @Json(name = "msgtype") override val msgType: String, /** * Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'. @@ -40,7 +40,7 @@ data class MessageVideoContent( @Json(name = "info") val videoInfo: VideoInfo? = null, /** - * Required. Required if the file is unencrypted. The URL (typically MXC URI) to the video clip. + * Required if the file is unencrypted. The URL (typically MXC URI) to the video clip. */ @Json(name = "url") override val url: String? = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/RoomVerificationUpdateTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/RoomVerificationUpdateTask.kt index 5a8f8e7ba5..d6118867ea 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/RoomVerificationUpdateTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/RoomVerificationUpdateTask.kt @@ -88,7 +88,7 @@ internal class DefaultRoomVerificationUpdateTask @Inject constructor( // done from another device of mine if (EventType.MESSAGE == event.type) { - val msgType = event.getClearContent().toModel()?.type + val msgType = event.getClearContent().toModel()?.msgType if (MessageType.MSGTYPE_VERIFICATION_REQUEST == msgType) { event.getClearContent().toModel()?.let { if (it.fromDevice != deviceId) { @@ -144,7 +144,7 @@ internal class DefaultRoomVerificationUpdateTask @Inject constructor( params.verificationService.onRoomEvent(event) } EventType.MESSAGE -> { - if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.type) { + if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.msgType) { params.verificationService.onRoomRequestReceived(event) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt index 911fc2a572..fc14b0a23a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt @@ -165,7 +165,7 @@ internal class DefaultVerificationService @Inject constructor( onRoomDoneReceived(event) } EventType.MESSAGE -> { - if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.type) { + if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.msgType) { onRoomRequestReceived(event) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index 9deb79136d..5d7a7c085f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -83,7 +83,7 @@ internal class LocalEchoEventFactory @Inject constructor( if (msgType == MessageType.MSGTYPE_TEXT || msgType == MessageType.MSGTYPE_EMOTE) { return createFormattedTextEvent(roomId, createTextContent(text, autoMarkdown), msgType) } - val content = MessageTextContent(type = msgType, body = text.toString()) + val content = MessageTextContent(msgType = msgType, body = text.toString()) return createEvent(roomId, content) } @@ -122,7 +122,7 @@ internal class LocalEchoEventFactory @Inject constructor( compatibilityText: String): Event { return createEvent(roomId, MessageTextContent( - type = msgType, + msgType = msgType, body = compatibilityText, relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId), newContent = createTextContent(newBodyText, newBodyAutoMarkdown) @@ -131,7 +131,8 @@ internal class LocalEchoEventFactory @Inject constructor( )) } - fun createReplaceTextOfReply(roomId: String, eventReplaced: TimelineEvent, + fun createReplaceTextOfReply(roomId: String, + eventReplaced: TimelineEvent, originalEvent: TimelineEvent, newBodyText: String, newBodyAutoMarkdown: Boolean, @@ -157,11 +158,11 @@ internal class LocalEchoEventFactory @Inject constructor( return createEvent(roomId, MessageTextContent( - type = msgType, + msgType = msgType, body = compatibilityText, relatesTo = RelationDefaultContent(RelationType.REPLACE, eventReplaced.root.eventId), newContent = MessageTextContent( - type = msgType, + msgType = msgType, format = MessageType.FORMAT_MATRIX_HTML, body = replyFallback, formattedBody = replyFormatted @@ -214,7 +215,7 @@ internal class LocalEchoEventFactory @Inject constructor( } val content = MessageImageContent( - type = MessageType.MSGTYPE_IMAGE, + msgType = MessageType.MSGTYPE_IMAGE, body = attachment.name ?: "image", info = ImageInfo( mimeType = attachment.mimeType, @@ -246,7 +247,7 @@ internal class LocalEchoEventFactory @Inject constructor( ) } val content = MessageVideoContent( - type = MessageType.MSGTYPE_VIDEO, + msgType = MessageType.MSGTYPE_VIDEO, body = attachment.name ?: "video", videoInfo = VideoInfo( mimeType = attachment.mimeType, @@ -265,7 +266,7 @@ internal class LocalEchoEventFactory @Inject constructor( private fun createAudioEvent(roomId: String, attachment: ContentAttachmentData): Event { val content = MessageAudioContent( - type = MessageType.MSGTYPE_AUDIO, + msgType = MessageType.MSGTYPE_AUDIO, body = attachment.name ?: "audio", audioInfo = AudioInfo( mimeType = attachment.mimeType?.takeIf { it.isNotBlank() } ?: "audio/mpeg", @@ -278,7 +279,7 @@ internal class LocalEchoEventFactory @Inject constructor( private fun createFileEvent(roomId: String, attachment: ContentAttachmentData): Event { val content = MessageFileContent( - type = MessageType.MSGTYPE_FILE, + msgType = MessageType.MSGTYPE_FILE, body = attachment.name ?: "file", info = FileInfo( mimeType = attachment.mimeType?.takeIf { it.isNotBlank() } @@ -349,7 +350,7 @@ internal class LocalEchoEventFactory @Inject constructor( val eventId = eventReplied.root.eventId ?: return null val content = MessageTextContent( - type = MessageType.MSGTYPE_TEXT, + msgType = MessageType.MSGTYPE_TEXT, format = MessageType.FORMAT_MATRIX_HTML, body = replyFallback, formattedBody = replyFormatted, @@ -383,7 +384,7 @@ internal class LocalEchoEventFactory @Inject constructor( * himself a reply, but it will contain the fallbacks, so we have to trim them. */ private fun bodyForReply(content: MessageContent?, originalContent: MessageContent?): TextContent { - when (content?.type) { + when (content?.msgType) { MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_NOTICE -> { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoRepository.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoRepository.kt index c924e891c8..fa43dde95e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoRepository.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoRepository.kt @@ -116,7 +116,7 @@ internal class LocalEchoRepository @Inject constructor(private val monarchy: Mon EventType.REACTION -> { val content = event.getClearContent().toModel() if (content != null) { - when (content.type) { + when (content.msgType) { MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_NOTICE, MessageType.MSGTYPE_LOCATION, @@ -127,11 +127,11 @@ internal class LocalEchoRepository @Inject constructor(private val monarchy: Mon MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_AUDIO -> { - // need to resend the attachement + // need to resend the attachment false } else -> { - Timber.e("Cannot resend message ${event.type} / ${content.type}") + Timber.e("Cannot resend message ${event.type} / ${content.msgType}") false } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/TextContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/TextContent.kt index 27b68e95eb..ae973b17f5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/TextContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/TextContent.kt @@ -33,7 +33,7 @@ data class TextContent( fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent { return MessageTextContent( - type = msgType, + msgType = msgType, format = MessageType.FORMAT_MATRIX_HTML.takeIf { formattedText != null }, body = text, formattedBody = formattedText diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt index bda3623078..10e7ceb692 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt @@ -41,7 +41,7 @@ internal class CryptoSyncHandler @Inject constructor(private val cryptoService: // Decrypt event if necessary decryptEvent(event, null) if (event.getClearType() == EventType.MESSAGE - && event.getClearContent()?.toModel()?.type == "m.bad.encrypted") { + && event.getClearContent()?.toModel()?.msgType == "m.bad.encrypted") { Timber.e("## handleToDeviceEvent() : Warning: Unable to decrypt to-device event : ${event.content}") } else { verificationService.onToDeviceEvent(event) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index 6080ae6332..c58270aff2 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -480,7 +480,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro val existingBody = messageContent?.body ?: "" if (existingBody != action.text) { room.editTextMessage(state.sendMode.timelineEvent.root.eventId ?: "", - messageContent?.type ?: MessageType.MSGTYPE_TEXT, + messageContent?.msgType ?: MessageType.MSGTYPE_TEXT, action.text, action.autoMarkdown) } else { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index aa81658bf9..8e175721ab 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -203,7 +203,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted private fun actionsForEvent(timelineEvent: TimelineEvent): List { val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel() ?: timelineEvent.root.getClearContent().toModel() - val type = messageContent?.type + val msgType = messageContent?.msgType return arrayListOf().apply { if (timelineEvent.root.sendState.hasFailed()) { @@ -230,7 +230,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted add(EventSharedAction.Delete(eventId)) } - if (canCopy(type)) { + if (canCopy(msgType)) { // TODO copy images? html? see ClipBoard add(EventSharedAction.Copy(messageContent!!.body)) } @@ -251,7 +251,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted add(EventSharedAction.ViewEditHistory(informationData)) } - if (canShare(type)) { + if (canShare(msgType)) { if (messageContent is MessageImageContent) { session.contentUrlResolver().resolveFullSize(messageContent.url)?.let { url -> add(EventSharedAction.Share(url)) @@ -296,7 +296,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted private fun canReply(event: TimelineEvent, messageContent: MessageContent?): Boolean { // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment if (event.root.getClearType() != EventType.MESSAGE) return false - return when (messageContent?.type) { + return when (messageContent?.msgType) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_NOTICE, MessageType.MSGTYPE_EMOTE, @@ -311,7 +311,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted private fun canQuote(event: TimelineEvent, messageContent: MessageContent?): Boolean { // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment if (event.root.getClearType() != EventType.MESSAGE) return false - return when (messageContent?.type) { + return when (messageContent?.msgType) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_NOTICE, MessageType.MSGTYPE_EMOTE, @@ -347,13 +347,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted // TODO if user is admin or moderator val messageContent = event.root.getClearContent().toModel() return event.root.senderId == myUserId && ( - messageContent?.type == MessageType.MSGTYPE_TEXT - || messageContent?.type == MessageType.MSGTYPE_EMOTE + messageContent?.msgType == MessageType.MSGTYPE_TEXT + || messageContent?.msgType == MessageType.MSGTYPE_EMOTE ) } - private fun canCopy(type: String?): Boolean { - return when (type) { + private fun canCopy(msgType: String?): Boolean { + return when (msgType) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_NOTICE, MessageType.MSGTYPE_EMOTE, @@ -363,8 +363,8 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } } - private fun canShare(type: String?): Boolean { - return when (type) { + private fun canShare(msgType: String?): Boolean { + return when (msgType) { MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_AUDIO, MessageType.MSGTYPE_VIDEO -> true diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 086dfe3754..65a6f5f244 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -229,7 +229,7 @@ class MessageItemFactory @Inject constructor( informationData: MessageInformationData, highlight: Boolean, callback: TimelineEventController.Callback?): DefaultItem? { - val text = stringProvider.getString(R.string.rendering_event_error_type_of_message_not_handled, messageContent.type) + val text = stringProvider.getString(R.string.rendering_event_error_type_of_message_not_handled, messageContent.msgType) return defaultItemFactory.create(text, informationData, highlight, callback) } @@ -258,7 +258,7 @@ class MessageItemFactory @Inject constructor( .highlighted(highlight) .mediaData(data) .apply { - if (messageContent.type == MessageType.MSGTYPE_STICKER_LOCAL) { + if (messageContent.msgType == MessageType.MSGTYPE_STICKER_LOCAL) { mode(ImageContentRenderer.Mode.STICKER) } else { clickListener( diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt index ed6bc9df62..294429368a 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt @@ -46,7 +46,7 @@ class DisplayableEventFormatter @Inject constructor( when (timelineEvent.root.getClearType()) { EventType.MESSAGE -> { timelineEvent.getLastMessageContent()?.let { messageContent -> - when (messageContent.type) { + when (messageContent.msgType) { MessageType.MSGTYPE_VERIFICATION_REQUEST -> { return simpleFormat(senderName, stringProvider.getString(R.string.verification_request), appendAuthor) }