diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/request/ApiTimelineEvent.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/request/ApiTimelineEvent.kt index dfd0a64..81fe26c 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/request/ApiTimelineEvent.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/request/ApiTimelineEvent.kt @@ -50,6 +50,18 @@ internal sealed class ApiTimelineEvent { ) } + @Serializable + @SerialName("m.room.canonical_alias") + internal data class CanonicalAlias( + @SerialName("event_id") val id: EventId, + @SerialName("content") val content: Content, + ) : ApiTimelineEvent() { + + @Serializable + internal data class Content( + @SerialName("alias") val alias: String + ) + } @Serializable @SerialName("m.room.avatar") diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomOverviewProcessor.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomOverviewProcessor.kt index 22d2061..7d3b400 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomOverviewProcessor.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomOverviewProcessor.kt @@ -21,10 +21,12 @@ internal class RoomOverviewProcessor( null -> combinedEvents.filterIsInstance().first().let { roomCreate -> val roomName = roomDisplayName(combinedEvents) val isGroup = roomToProcess.directMessage == null + val processedName = roomName ?: roomToProcess.directMessage?.let { + roomMembersService.find(roomToProcess.roomId, it)?.let { it.displayName ?: it.id.value } + } + RoomOverview( - roomName = roomName ?: roomToProcess.directMessage?.let { - roomMembersService.find(roomToProcess.roomId, it)?.let { it.displayName ?: it.id.value } - }, + roomName = processedName, roomCreationUtc = roomCreate.utcTimestamp, lastMessage = lastMessage, roomId = roomToProcess.roomId, @@ -40,6 +42,7 @@ internal class RoomOverviewProcessor( isEncrypted = isEncrypted, ) } + else -> { previousState.copy( roomName = previousState.roomName ?: roomDisplayName(combinedEvents), @@ -60,7 +63,8 @@ internal class RoomOverviewProcessor( private fun roomDisplayName(combinedEvents: List): String? { val roomName = combinedEvents.filterIsInstance().lastOrNull() - return roomName?.content?.name + return (roomName?.content?.name) + ?: combinedEvents.filterIsInstance().lastOrNull()?.content?.alias } private suspend fun roomAvatar( @@ -75,6 +79,7 @@ internal class RoomOverviewProcessor( val filterIsInstance = combinedEvents.filterIsInstance() filterIsInstance.lastOrNull()?.content?.url?.convertMxUrToUrl(homeServerUrl)?.let { AvatarUrl(it) } } + else -> membersService.find(roomId, dmUser)?.avatarUrl } } diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/TimelineEventsProcessor.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/TimelineEventsProcessor.kt index ee68463..0ac76c1 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/TimelineEventsProcessor.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/TimelineEventsProcessor.kt @@ -38,6 +38,7 @@ internal class TimelineEventsProcessor( is ApiTimelineEvent.RoomMember -> null is ApiTimelineEvent.RoomName -> null is ApiTimelineEvent.RoomTopic -> null + is ApiTimelineEvent.CanonicalAlias -> null ApiTimelineEvent.Ignored -> null } roomEvent