diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a415dac53be..71584b9c5b2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -145,7 +145,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" } molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" } timber = "com.jakewharton.timber:timber:5.0.1" -matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.37" +matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.38" sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" } sqldelight-driver-jvm = { module = "com.squareup.sqldelight:sqlite-driver", version.ref = "sqldelight" } sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions", version.ref = "sqldelight" } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/NotificationMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/NotificationMapper.kt index a5db0950355..6f1c3b494b1 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/NotificationMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/NotificationMapper.kt @@ -20,6 +20,7 @@ import io.element.android.libraries.core.bool.orFalse import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.core.RoomId import io.element.android.libraries.matrix.api.core.SessionId +import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.api.notification.NotificationContent import io.element.android.libraries.matrix.api.notification.NotificationData import io.element.android.libraries.matrix.api.room.RoomMembershipState @@ -39,6 +40,8 @@ class NotificationMapper( roomId: RoomId, notificationItem: NotificationItem ): NotificationData { + notificationItem.event.use { (it as NotificationEvent.Timeline).event } + val senderId = UserId(notificationItem.senderInfo.senderId) return notificationItem.use { item -> NotificationData( eventId = eventId, @@ -50,8 +53,8 @@ class NotificationMapper( isDirect = item.roomInfo.isDirect, isEncrypted = item.roomInfo.isEncrypted.orFalse(), isNoisy = item.isNoisy.orFalse(), - timestamp = item.timestamp() ?: clock.epochMillis(), - content = item.event.use(notificationContentMapper::map), + timestamp = item.timestamp(clock), + content = item.event.use { notificationContentMapper.map(senderId, it) }, contentUrl = null, ) } @@ -63,9 +66,9 @@ class NotificationContentMapper( ) { private val timelineEventToNotificationContentMapper = TimelineEventToNotificationContentMapper() - fun map(notificationEvent: NotificationEvent): NotificationContent = + fun map(senderId: UserId, notificationEvent: NotificationEvent): NotificationContent = when (notificationEvent) { - is NotificationEvent.Timeline -> timelineEventToNotificationContentMapper.map(notificationEvent.event) + is NotificationEvent.Timeline -> timelineEventToNotificationContentMapper.map(senderId, notificationEvent.event) is NotificationEvent.Invite -> NotificationContent.StateEvent.RoomMemberContent( userId = sessionId.value, membershipState = RoomMembershipState.INVITE, @@ -73,6 +76,8 @@ class NotificationContentMapper( } } -private fun NotificationItem.timestamp(): Long? { - return (this.event as? NotificationEvent.Timeline)?.event?.timestamp()?.toLong() +private fun NotificationItem.timestamp(clock: SystemClock): Long { + // FIXME we can't get the timestamp from the notification item anymore, so we need to fake it +// return (this.event as? NotificationEvent.Timeline)?.event?.timestamp()?.toLong() + return clock.epochMillis() } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt index bb281ba4d71..3dc432ad279 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt @@ -42,7 +42,7 @@ class RustNotificationService( filterByPushRules: Boolean, ): Result = withContext(dispatchers.io) { runCatching { - val item = notificationClient.getNotificationWithSlidingSync(roomId.value, eventId.value) + val item = notificationClient.getNotification(roomId.value, eventId.value) item?.use { notificationMapper.map(eventId, roomId, it) } 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 3121c9240da..1bf11b8e935 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 @@ -22,16 +22,15 @@ import io.element.android.libraries.matrix.impl.room.RoomMemberMapper import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper import org.matrix.rustcomponents.sdk.MessageLikeEventContent import org.matrix.rustcomponents.sdk.StateEventContent -import org.matrix.rustcomponents.sdk.TimelineEvent import org.matrix.rustcomponents.sdk.TimelineEventType import org.matrix.rustcomponents.sdk.use import javax.inject.Inject class TimelineEventToNotificationContentMapper @Inject constructor() { - fun map(timelineEvent: TimelineEvent): NotificationContent { - return timelineEvent.use { - it.eventType().toContent(senderId = UserId(timelineEvent.senderId())) + fun map(senderId: UserId, timelineEventType: TimelineEventType): NotificationContent { + return timelineEventType.use { + it.toContent(senderId = senderId) } } } 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 397aa1e5b87..5503c22b1db 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 @@ -140,7 +140,7 @@ class RustMatrixRoom( override val avatarUrl: String? get() { - return innerRoom.avatarUrl() + return roomListItem.avatarUrl() ?: innerRoom.avatarUrl() } override val isEncrypted: Boolean