diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt index 8565e4c747..290a54c502 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt @@ -61,6 +61,7 @@ sealed interface NotificationContent { ) : MessageLike data object RoomRedaction : MessageLike data object Sticker : MessageLike + data class Poll(val question: String) : MessageLike } sealed interface StateEvent : NotificationContent { diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt index e30e57113d..b82716cc2d 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt @@ -94,6 +94,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon } MessageLikeEventContent.RoomRedaction -> NotificationContent.MessageLike.RoomRedaction MessageLikeEventContent.Sticker -> NotificationContent.MessageLike.Sticker + is MessageLikeEventContent.Poll -> NotificationContent.MessageLike.Poll(question) } } } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomContentForwarder.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomContentForwarder.kt index 8ee0361ace..d539ec6a53 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomContentForwarder.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomContentForwarder.kt @@ -27,7 +27,6 @@ import org.matrix.rustcomponents.sdk.Room import org.matrix.rustcomponents.sdk.RoomListService import org.matrix.rustcomponents.sdk.TimelineDiff import org.matrix.rustcomponents.sdk.TimelineListener -import org.matrix.rustcomponents.sdk.genTransactionId import kotlin.time.Duration.Companion.milliseconds /** @@ -61,7 +60,7 @@ class RoomContentForwarder( // Sending a message requires a registered timeline listener targetRoom.addTimelineListener(NoOpTimelineListener) withTimeout(timeoutMs.milliseconds) { - targetRoom.send(content, genTransactionId()) + targetRoom.send(content) } } // After sending, we remove the timeline diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt index 4a8a3f9bee..d879bcc53d 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt @@ -67,7 +67,6 @@ import org.matrix.rustcomponents.sdk.RoomMember import org.matrix.rustcomponents.sdk.RoomMessageEventContentWithoutRelation import org.matrix.rustcomponents.sdk.RoomSubscription import org.matrix.rustcomponents.sdk.SendAttachmentJoinHandle -import org.matrix.rustcomponents.sdk.genTransactionId import org.matrix.rustcomponents.sdk.messageEventContentFromHtml import org.matrix.rustcomponents.sdk.messageEventContentFromMarkdown import timber.log.Timber @@ -241,10 +240,9 @@ class RustMatrixRoom( } override suspend fun sendMessage(body: String, htmlBody: String?): Result = withContext(roomDispatcher) { - val transactionId = genTransactionId() messageEventContentFromParts(body, htmlBody).use { content -> runCatching { - innerRoom.send(content, transactionId) + innerRoom.send(content) } } } @@ -253,26 +251,27 @@ class RustMatrixRoom( withContext(roomDispatcher) { if (originalEventId != null) { runCatching { - innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value, transactionId?.value) + innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value) } } else { runCatching { transactionId?.let { cancelSend(it) } - innerRoom.send(messageEventContentFromParts(body, htmlBody), genTransactionId()) + innerRoom.send(messageEventContentFromParts(body, htmlBody)) } } } override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result = withContext(roomDispatcher) { runCatching { - innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventId.value, genTransactionId()) + innerRoom.getEventTimelineItemByEventId(eventId.value).use { eventTimelineItem -> + innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventTimelineItem) + } } } override suspend fun redactEvent(eventId: EventId, reason: String?) = withContext(roomDispatcher) { - val transactionId = genTransactionId() runCatching { - innerRoom.redact(eventId.value, reason, transactionId) + innerRoom.redact(eventId.value, reason) } } @@ -416,7 +415,6 @@ class RustMatrixRoom( description = description, zoomLevel = zoomLevel?.toUByte(), assetType = assetType?.toInner(), - txnId = genTransactionId(), ) } } @@ -433,7 +431,6 @@ class RustMatrixRoom( answers = answers, maxSelections = maxSelections.toUByte(), pollKind = pollKind.toInner(), - txnId = genTransactionId(), ) } } @@ -446,7 +443,6 @@ class RustMatrixRoom( innerRoom.sendPollResponse( pollStartId = pollStartId.value, answers = answers, - txnId = genTransactionId(), ) } } @@ -459,7 +455,6 @@ class RustMatrixRoom( innerRoom.endPoll( pollStartId = pollStartId.value, text = text, - txnId = genTransactionId(), ) } }