Merge branch 'develop' into feature/fga/live_location_rendering

This commit is contained in:
ganfra 2026-04-10 09:50:44 +02:00
commit d6999b5334
705 changed files with 6439 additions and 2804 deletions

View file

@ -49,7 +49,6 @@ private fun StateEventContent.toContent(): NotificationContent.StateEvent {
StateEventContent.PolicyRuleRoom -> NotificationContent.StateEvent.PolicyRuleRoom
StateEventContent.PolicyRuleServer -> NotificationContent.StateEvent.PolicyRuleServer
StateEventContent.PolicyRuleUser -> NotificationContent.StateEvent.PolicyRuleUser
StateEventContent.RoomAliases -> NotificationContent.StateEvent.RoomAliases
StateEventContent.RoomAvatar -> NotificationContent.StateEvent.RoomAvatar
StateEventContent.RoomCanonicalAlias -> NotificationContent.StateEvent.RoomCanonicalAlias
StateEventContent.RoomCreate -> NotificationContent.StateEvent.RoomCreate

View file

@ -16,7 +16,6 @@ fun StateEventType.map(): RustStateEventType = when (this) {
StateEventType.PolicyRuleServer -> RustStateEventType.PolicyRuleServer
StateEventType.PolicyRuleUser -> RustStateEventType.PolicyRuleUser
StateEventType.CallMember -> RustStateEventType.CallMember
StateEventType.RoomAliases -> RustStateEventType.RoomAliases
StateEventType.RoomAvatar -> RustStateEventType.RoomAvatar
StateEventType.RoomCanonicalAlias -> RustStateEventType.RoomCanonicalAlias
StateEventType.RoomCreate -> RustStateEventType.RoomCreate
@ -46,7 +45,6 @@ fun RustStateEventType.map(): StateEventType = when (this) {
RustStateEventType.PolicyRuleServer -> StateEventType.PolicyRuleServer
RustStateEventType.PolicyRuleUser -> StateEventType.PolicyRuleUser
RustStateEventType.CallMember -> StateEventType.CallMember
RustStateEventType.RoomAliases -> StateEventType.RoomAliases
RustStateEventType.RoomAvatar -> StateEventType.RoomAvatar
RustStateEventType.RoomCanonicalAlias -> StateEventType.RoomCanonicalAlias
RustStateEventType.RoomCreate -> StateEventType.RoomCreate

View file

@ -23,6 +23,7 @@ import io.element.android.libraries.matrix.api.room.JoinedRoom
import io.element.android.libraries.matrix.api.room.isDm
import io.element.android.libraries.matrix.api.room.location.AssetType
import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem
import io.element.android.libraries.matrix.api.timeline.MsgType
import io.element.android.libraries.matrix.api.timeline.ReceiptType
import io.element.android.libraries.matrix.api.timeline.Timeline
import io.element.android.libraries.matrix.api.timeline.TimelineException
@ -271,8 +272,16 @@ class RustTimeline(
body: String,
htmlBody: String?,
intentionalMentions: List<IntentionalMention>,
msgType: MsgType,
asPlainText: Boolean,
): Result<Unit> = withContext(dispatcher) {
MessageEventContent.from(body, htmlBody, intentionalMentions).use { content ->
MessageEventContent.from(
body = body,
htmlBody = htmlBody,
intentionalMentions = intentionalMentions,
msgType = msgType,
asPlainText = asPlainText,
).use { content ->
runCatchingExceptions<Unit> {
inner.send(content)
}
@ -337,9 +346,15 @@ class RustTimeline(
htmlBody: String?,
intentionalMentions: List<IntentionalMention>,
fromNotification: Boolean,
msgType: MsgType,
): Result<Unit> = withContext(dispatcher) {
runCatchingExceptions {
val msg = MessageEventContent.from(body, htmlBody, intentionalMentions)
val msg = MessageEventContent.from(
body = body,
htmlBody = htmlBody,
intentionalMentions = intentionalMentions,
msgType = msgType,
)
inner.sendReply(
msg = msg,
eventId = repliedToEventId.value,

View file

@ -233,7 +233,6 @@ private fun RustOtherState.map(): OtherState {
RustOtherState.PolicyRuleRoom -> OtherState.PolicyRuleRoom
RustOtherState.PolicyRuleServer -> OtherState.PolicyRuleServer
RustOtherState.PolicyRuleUser -> OtherState.PolicyRuleUser
RustOtherState.RoomAliases -> OtherState.RoomAliases
is RustOtherState.RoomAvatar -> OtherState.RoomAvatar(url)
RustOtherState.RoomCanonicalAlias -> OtherState.RoomCanonicalAlias
RustOtherState.RoomCreate -> OtherState.RoomCreate

View file

@ -9,20 +9,54 @@
package io.element.android.libraries.matrix.impl.util
import io.element.android.libraries.matrix.api.room.IntentionalMention
import io.element.android.libraries.matrix.api.timeline.MsgType
import io.element.android.libraries.matrix.impl.room.map
import org.matrix.rustcomponents.sdk.MessageContent
import org.matrix.rustcomponents.sdk.MessageType
import org.matrix.rustcomponents.sdk.RoomMessageEventContentWithoutRelation
import org.matrix.rustcomponents.sdk.TextMessageContent
import org.matrix.rustcomponents.sdk.contentWithoutRelationFromMessage
import org.matrix.rustcomponents.sdk.messageEventContentFromHtml
import org.matrix.rustcomponents.sdk.messageEventContentFromHtmlAsEmote
import org.matrix.rustcomponents.sdk.messageEventContentFromMarkdown
import org.matrix.rustcomponents.sdk.messageEventContentFromMarkdownAsEmote
/**
* Creates a [RoomMessageEventContentWithoutRelation] from a body, an html body and a list of mentions.
*/
object MessageEventContent {
fun from(body: String, htmlBody: String?, intentionalMentions: List<IntentionalMention>): RoomMessageEventContentWithoutRelation {
return if (htmlBody != null) {
messageEventContentFromHtml(body, htmlBody)
} else {
messageEventContentFromMarkdown(body)
}.withMentions(intentionalMentions.map())
fun from(
body: String,
htmlBody: String?,
intentionalMentions: List<IntentionalMention>,
msgType: MsgType = MsgType.MSG_TYPE_TEXT,
asPlainText: Boolean = false,
): RoomMessageEventContentWithoutRelation {
return when {
asPlainText -> contentWithoutRelationFromMessage(
MessageContent(
msgType = MessageType.Text(
TextMessageContent(
body = body,
formatted = null,
)
),
body = body,
isEdited = false,
mentions = null,
)
)
htmlBody != null -> if (msgType == MsgType.MSG_TYPE_EMOTE) {
messageEventContentFromHtmlAsEmote(body, htmlBody)
} else {
messageEventContentFromHtml(body, htmlBody)
}
else -> if (msgType == MsgType.MSG_TYPE_EMOTE) {
messageEventContentFromMarkdownAsEmote(body)
} else {
messageEventContentFromMarkdown(body)
}
}
.withMentions(intentionalMentions.map())
}
}

View file

@ -14,10 +14,9 @@ import io.element.android.libraries.matrix.test.A_USER_ID
import org.matrix.rustcomponents.sdk.EventOrTransactionId
import org.matrix.rustcomponents.sdk.EventSendState
import org.matrix.rustcomponents.sdk.EventTimelineItem
import org.matrix.rustcomponents.sdk.EventTimelineItemDebugInfo
import org.matrix.rustcomponents.sdk.LazyTimelineItemProvider
import org.matrix.rustcomponents.sdk.ProfileDetails
import org.matrix.rustcomponents.sdk.Receipt
import org.matrix.rustcomponents.sdk.ShieldState
import org.matrix.rustcomponents.sdk.TimelineItemContent
import uniffi.matrix_sdk_ui.EventItemOrigin
@ -26,37 +25,35 @@ internal fun aRustEventTimelineItem(
eventOrTransactionId: EventOrTransactionId = EventOrTransactionId.EventId(AN_EVENT_ID.value),
sender: String = A_USER_ID.value,
senderProfile: ProfileDetails = ProfileDetails.Unavailable,
forwarder: String? = null,
forwarderProfile: ProfileDetails? = null,
isOwn: Boolean = true,
isEditable: Boolean = true,
content: TimelineItemContent = aRustTimelineItemContentMsgLike(),
eventTypeRaw: String? = null,
timestamp: ULong = 0uL,
debugInfo: EventTimelineItemDebugInfo = anEventTimelineItemDebugInfo(),
localSendState: EventSendState? = null,
localCreatedAt: ULong? = null,
readReceipts: Map<String, Receipt> = emptyMap(),
origin: EventItemOrigin? = EventItemOrigin.SYNC,
canBeRepliedTo: Boolean = true,
shieldsState: ShieldState = ShieldState.None,
localCreatedAt: ULong? = null,
forwarder: String? = null,
forwarderProfile: ProfileDetails? = null,
lazyProvider: LazyTimelineItemProvider = FakeFfiLazyTimelineItemProvider(),
) = EventTimelineItem(
isRemote = isRemote,
eventOrTransactionId = eventOrTransactionId,
sender = sender,
senderProfile = senderProfile,
timestamp = timestamp,
isOwn = isOwn,
isEditable = isEditable,
canBeRepliedTo = canBeRepliedTo,
content = content,
localSendState = localSendState,
readReceipts = readReceipts,
origin = origin,
localCreatedAt = localCreatedAt,
lazyProvider = FakeFfiLazyTimelineItemProvider(
debugInfo = debugInfo,
shieldsState = shieldsState,
),
forwarder = forwarder,
forwarderProfile = forwarderProfile,
isOwn = isOwn,
isEditable = isEditable,
content = content,
eventTypeRaw = eventTypeRaw,
timestamp = timestamp,
localSendState = localSendState,
localCreatedAt = localCreatedAt,
readReceipts = readReceipts,
origin = origin,
canBeRepliedTo = canBeRepliedTo,
lazyProvider = lazyProvider,
)

View file

@ -20,7 +20,6 @@ class StateEventTypeTest {
assertThat(RustStateEventType.PolicyRuleRoom.map()).isEqualTo(StateEventType.PolicyRuleRoom)
assertThat(RustStateEventType.PolicyRuleServer.map()).isEqualTo(StateEventType.PolicyRuleServer)
assertThat(RustStateEventType.PolicyRuleUser.map()).isEqualTo(StateEventType.PolicyRuleUser)
assertThat(RustStateEventType.RoomAliases.map()).isEqualTo(StateEventType.RoomAliases)
assertThat(RustStateEventType.RoomAvatar.map()).isEqualTo(StateEventType.RoomAvatar)
assertThat(RustStateEventType.RoomCanonicalAlias.map()).isEqualTo(StateEventType.RoomCanonicalAlias)
assertThat(RustStateEventType.RoomCreate.map()).isEqualTo(StateEventType.RoomCreate)
@ -47,7 +46,6 @@ class StateEventTypeTest {
assertThat(StateEventType.PolicyRuleRoom.map()).isEqualTo(RustStateEventType.PolicyRuleRoom)
assertThat(StateEventType.PolicyRuleServer.map()).isEqualTo(RustStateEventType.PolicyRuleServer)
assertThat(StateEventType.PolicyRuleUser.map()).isEqualTo(RustStateEventType.PolicyRuleUser)
assertThat(StateEventType.RoomAliases.map()).isEqualTo(RustStateEventType.RoomAliases)
assertThat(StateEventType.RoomAvatar.map()).isEqualTo(RustStateEventType.RoomAvatar)
assertThat(StateEventType.RoomCanonicalAlias.map()).isEqualTo(RustStateEventType.RoomCanonicalAlias)
assertThat(StateEventType.RoomCreate.map()).isEqualTo(RustStateEventType.RoomCreate)