Use awaitRoomSummary

This commit is contained in:
ganfra 2022-07-06 18:39:56 +02:00
parent ebd491c6f0
commit 2acfce2d20
6 changed files with 6 additions and 6 deletions

View File

@ -51,7 +51,7 @@ internal class DefaultLeaveRoomTask @Inject constructor(
} }
private suspend fun leaveRoom(roomId: String, reason: String?) { private suspend fun leaveRoom(roomId: String, reason: String?) {
val roomSummary = roomSummaryDataSource.getRoomSummary(roomId) val roomSummary = roomSummaryDataSource.awaitRoomSummary(roomId)
if (roomSummary?.membership?.isActive() == false) { if (roomSummary?.membership?.isActive() == false) {
Timber.v("Room $roomId is not joined so can't be left") Timber.v("Room $roomId is not joined so can't be left")
return return

View File

@ -53,7 +53,7 @@ internal class DefaultSpace(
) { ) {
// Find best via // Find best via
val bestVia = viaServers val bestVia = viaServers
?: (spaceSummaryDataSource.getRoomSummary(roomId) ?: (spaceSummaryDataSource.awaitRoomSummary(roomId)
?.takeIf { it.joinRules == RoomJoinRules.RESTRICTED } ?.takeIf { it.joinRules == RoomJoinRules.RESTRICTED }
?.let { ?.let {
// for restricted room, best to take via from users that can invite in the // for restricted room, best to take via from users that can invite in the

View File

@ -246,7 +246,7 @@ internal class DefaultSpaceService @Inject constructor(
// and if client want to bypass, it could use sendStateEvent directly? // and if client want to bypass, it could use sendStateEvent directly?
if (canonical) { if (canonical) {
// check that we can send m.child in the parent room // check that we can send m.child in the parent room
if (roomSummaryDataSource.getRoomSummary(parentSpaceId)?.membership != Membership.JOIN) { if (roomSummaryDataSource.awaitRoomSummary(parentSpaceId)?.membership != Membership.JOIN) {
throw UnsupportedOperationException("Cannot add canonical child if not member of parent") throw UnsupportedOperationException("Cannot add canonical child if not member of parent")
} }
val powerLevelsEvent = stateEventDataSource.getStateEvent( val powerLevelsEvent = stateEventDataSource.getStateEvent(

View File

@ -58,7 +58,7 @@ class CallUserMapper(private val session: Session, private val protocolsChecker:
protocolsChecker.awaitCheckProtocols() protocolsChecker.awaitCheckProtocols()
if (!protocolsChecker.supportVirtualRooms) return if (!protocolsChecker.supportVirtualRooms) return
val invitedRoom = session.getRoom(invitedRoomId) ?: return val invitedRoom = session.getRoom(invitedRoomId) ?: return
val inviterId = invitedRoom.roomSummary()?.inviterId ?: return val inviterId = invitedRoom.awaitRoomSummary()?.inviterId ?: return
val nativeLookup = session.sipNativeLookup(inviterId).firstOrNull() ?: return val nativeLookup = session.sipNativeLookup(inviterId).firstOrNull() ?: return
if (nativeLookup.fields.containsKey("is_virtual")) { if (nativeLookup.fields.containsKey("is_virtual")) {
val nativeUser = nativeLookup.userId val nativeUser = nativeLookup.userId

View File

@ -294,7 +294,7 @@ class RoomListViewModel @AssistedInject constructor(
session.getRoom(action.roomId)?.let { room -> session.getRoom(action.roomId)?.let { room ->
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
try { try {
if (room.roomSummary()?.hasTag(action.tag) == false) { if (room.awaitRoomSummary()?.hasTag(action.tag) == false) {
// Favorite and low priority tags are exclusive, so maybe delete the other tag first // Favorite and low priority tags are exclusive, so maybe delete the other tag first
action.tag.otherTag() action.tag.otherTag()
?.takeIf { room.roomSummary()?.hasTag(it).orFalse() } ?.takeIf { room.roomSummary()?.hasTag(it).orFalse() }

View File

@ -122,7 +122,7 @@ class InvitesAcceptor @Inject constructor(
// if we got 404 on invites, the inviting user have left or the hs is off. // if we got 404 on invites, the inviting user have left or the hs is off.
if (failure is Failure.ServerError && failure.httpCode == 404) { if (failure is Failure.ServerError && failure.httpCode == 404) {
val room = getRoom(roomId) ?: return val room = getRoom(roomId) ?: return
val inviterId = room.roomSummary()?.inviterId val inviterId = room.awaitRoomSummary()?.inviterId
// if the inviting user is on the same HS, there can only be one cause: they left, so we try to reject the invite. // if the inviting user is on the same HS, there can only be one cause: they left, so we try to reject the invite.
if (inviterId?.endsWith(sessionParams.credentials.homeServer.orEmpty()).orFalse()) { if (inviterId?.endsWith(sessionParams.credentials.homeServer.orEmpty()).orFalse()) {
shouldRejectRoomIds.add(roomId) shouldRejectRoomIds.add(roomId)