Fix API breaks:

- Add `Beacon` variants for `NotificationData`.
- Add `call` and `status` to `UserProfile`.
This commit is contained in:
Jorge Martín
2026-07-14 15:45:26 +02:00
parent b0c9947a11
commit 09b7732c1b
6 changed files with 21 additions and 2 deletions
@@ -89,6 +89,8 @@ sealed interface NotificationContent {
val senderId: UserId, val senderId: UserId,
val question: String, val question: String,
) : MessageLike ) : MessageLike
data object Beacon : MessageLike
} }
sealed interface StateEvent : NotificationContent { sealed interface StateEvent : NotificationContent {
@@ -116,6 +118,7 @@ sealed interface NotificationContent {
data class RoomTopic(val topic: String) : StateEvent data class RoomTopic(val topic: String) : StateEvent
data object SpaceChild : StateEvent data object SpaceChild : StateEvent
data object SpaceParent : StateEvent data object SpaceParent : StateEvent
data object BeaconInfo : StateEvent
} }
data class Invite( data class Invite(
@@ -71,6 +71,7 @@ private fun StateEventContent.toContent(): NotificationContent.StateEvent {
is StateEventContent.RoomTopic -> NotificationContent.StateEvent.RoomTopic(topic) is StateEventContent.RoomTopic -> NotificationContent.StateEvent.RoomTopic(topic)
StateEventContent.SpaceChild -> NotificationContent.StateEvent.SpaceChild StateEventContent.SpaceChild -> NotificationContent.StateEvent.SpaceChild
StateEventContent.SpaceParent -> NotificationContent.StateEvent.SpaceParent StateEventContent.SpaceParent -> NotificationContent.StateEvent.SpaceParent
StateEventContent.BeaconInfo -> NotificationContent.StateEvent.BeaconInfo
} }
} }
@@ -108,6 +109,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
) )
MessageLikeEventContent.Sticker -> NotificationContent.MessageLike.Sticker MessageLikeEventContent.Sticker -> NotificationContent.MessageLike.Sticker
is MessageLikeEventContent.Poll -> NotificationContent.MessageLike.Poll(senderId, question) is MessageLikeEventContent.Poll -> NotificationContent.MessageLike.Poll(senderId, question)
MessageLikeEventContent.Beacon -> NotificationContent.MessageLike.Beacon
} }
} }
} }
@@ -90,6 +90,8 @@ class RustMatrixClientTest {
userId = userId, userId = userId,
displayName = A_USER_NAME, displayName = A_USER_NAME,
avatarUrl = AN_AVATAR_URL, avatarUrl = AN_AVATAR_URL,
status = null,
call = null,
) )
}, },
), ),
@@ -9,14 +9,20 @@
package io.element.android.libraries.matrix.impl.fixtures.factories package io.element.android.libraries.matrix.impl.fixtures.factories
import io.element.android.libraries.matrix.test.A_USER_ID import io.element.android.libraries.matrix.test.A_USER_ID
import org.matrix.rustcomponents.sdk.UserCall
import org.matrix.rustcomponents.sdk.UserProfile import org.matrix.rustcomponents.sdk.UserProfile
import org.matrix.rustcomponents.sdk.UserStatus
internal fun aRustUserProfile( internal fun aRustUserProfile(
userId: String = A_USER_ID.value, userId: String = A_USER_ID.value,
displayName: String = "displayName", displayName: String = "displayName",
avatarUrl: String = "avatarUrl", avatarUrl: String = "avatarUrl",
status: UserStatus? = null,
call: UserCall? = null,
) = UserProfile( ) = UserProfile(
userId = userId, userId = userId,
displayName = displayName, displayName = displayName,
avatarUrl = avatarUrl, avatarUrl = avatarUrl,
status = status,
call = call,
) )
@@ -9,6 +9,7 @@
package io.element.android.libraries.matrix.impl.fixtures.fakes package io.element.android.libraries.matrix.impl.fixtures.fakes
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustSession import io.element.android.libraries.matrix.impl.fixtures.factories.aRustSession
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustUserProfile
import io.element.android.libraries.matrix.test.A_DEVICE_ID import io.element.android.libraries.matrix.test.A_DEVICE_ID
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
import io.element.android.libraries.matrix.test.A_USER_ID import io.element.android.libraries.matrix.test.A_USER_ID
@@ -49,7 +50,7 @@ class FakeFfiClient(
private val session: Session = aRustSession(), private val session: Session = aRustSession(),
private val clearCachesResult: () -> Unit = { lambdaError() }, private val clearCachesResult: () -> Unit = { lambdaError() },
private val withUtdHook: (UnableToDecryptDelegate) -> Unit = { lambdaError() }, private val withUtdHook: (UnableToDecryptDelegate) -> Unit = { lambdaError() },
private val getProfileResult: (String) -> UserProfile = { UserProfile(userId = userId, displayName = null, avatarUrl = null) }, private val getProfileResult: (String) -> UserProfile = { aRustUserProfile() },
private val homeserverLoginDetailsResult: () -> HomeserverLoginDetails = { lambdaError() }, private val homeserverLoginDetailsResult: () -> HomeserverLoginDetails = { lambdaError() },
private val getStoreSizesResult: () -> StoreSizes = { lambdaError() }, private val getStoreSizesResult: () -> StoreSizes = { lambdaError() },
private val createRoomResult: (CreateRoomParameters) -> String = { lambdaError() }, private val createRoomResult: (CreateRoomParameters) -> String = { lambdaError() },
@@ -299,6 +299,10 @@ class DefaultNotifiableEventResolver(
Timber.tag(loggerTag.value).d("Ignoring notification for sticker") Timber.tag(loggerTag.value).d("Ignoring notification for sticker")
throw NotificationResolverException.EventFilteredOut throw NotificationResolverException.EventFilteredOut
} }
NotificationContent.MessageLike.Beacon -> {
Timber.tag(loggerTag.value).d("Ignoring notification for beacon")
throw NotificationResolverException.EventFilteredOut
}
is NotificationContent.StateEvent.RoomMemberContent, is NotificationContent.StateEvent.RoomMemberContent,
NotificationContent.StateEvent.PolicyRuleRoom, NotificationContent.StateEvent.PolicyRuleRoom,
NotificationContent.StateEvent.PolicyRuleServer, NotificationContent.StateEvent.PolicyRuleServer,
@@ -318,7 +322,8 @@ class DefaultNotifiableEventResolver(
NotificationContent.StateEvent.RoomTombstone, NotificationContent.StateEvent.RoomTombstone,
is NotificationContent.StateEvent.RoomTopic, is NotificationContent.StateEvent.RoomTopic,
NotificationContent.StateEvent.SpaceChild, NotificationContent.StateEvent.SpaceChild,
NotificationContent.StateEvent.SpaceParent -> { NotificationContent.StateEvent.SpaceParent,
NotificationContent.StateEvent.BeaconInfo -> {
Timber.tag(loggerTag.value).d("Ignoring notification for state event ${content.javaClass.simpleName}") Timber.tag(loggerTag.value).d("Ignoring notification for state event ${content.javaClass.simpleName}")
throw NotificationResolverException.EventFilteredOut throw NotificationResolverException.EventFilteredOut
} }