diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt index c9fb8fbccd..7b01824c6c 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt @@ -56,7 +56,7 @@ class JitsiService @Inject constructor( // Build data for a jitsi widget val widgetId: String = WidgetType.Jitsi.preferred + "_" + session.myUserId + "_" + System.currentTimeMillis() val preferredJitsiDomain = tryOrNull { - rawService.getElementWellknown(session.myUserId) + rawService.getElementWellknown(session.sessionParams) ?.jitsiServer ?.preferredDomain } diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt index 2f0b6e5ec9..88e8d68155 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt @@ -86,7 +86,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted setState { copy(createAndInviteState = Loading()) } viewModelScope.launch(Dispatchers.IO) { - val adminE2EByDefault = rawService.getElementWellknown(session.myUserId) + val adminE2EByDefault = rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true diff --git a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt index bfa56cfb9e..cf75bdf1b6 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt @@ -35,7 +35,7 @@ class DirectRoomHelper @Inject constructor( if (existingRoomId != null) { roomId = existingRoomId } else { - val adminE2EByDefault = rawService.getElementWellknown(session.myUserId) + val adminE2EByDefault = rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true diff --git a/vector/src/main/java/im/vector/app/features/homeserver/HomeServerCapabilitiesViewModel.kt b/vector/src/main/java/im/vector/app/features/homeserver/HomeServerCapabilitiesViewModel.kt index 05fd825558..083b843b33 100644 --- a/vector/src/main/java/im/vector/app/features/homeserver/HomeServerCapabilitiesViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/homeserver/HomeServerCapabilitiesViewModel.kt @@ -70,7 +70,7 @@ class HomeServerCapabilitiesViewModel @AssistedInject constructor( private fun initAdminE2eByDefault() { viewModelScope.launch(Dispatchers.IO) { val adminE2EByDefault = tryOrNull { - rawService.getElementWellknown(session.myUserId) + rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true } ?: true diff --git a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt index c1118e40cb..a6959ff116 100644 --- a/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt +++ b/vector/src/main/java/im/vector/app/features/raw/wellknown/ElementWellKnownExt.kt @@ -16,11 +16,14 @@ package im.vector.app.features.raw.wellknown +import org.matrix.android.sdk.api.auth.data.SessionParams import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService -suspend fun RawService.getElementWellknown(userId: String): ElementWellKnown? { - return tryOrNull { getWellknown(userId) } +suspend fun RawService.getElementWellknown(sessionParams: SessionParams): ElementWellKnown? { + // By default we use the domain of the userId to retrieve the .well-known data + val domain = sessionParams.userId.substringAfter(":") + return tryOrNull { getWellknown(domain) } ?.let { ElementWellKnownMapper.from(it) } } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt index 8c8d17dd46..bd7e176247 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt @@ -72,7 +72,7 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init private fun initAdminE2eByDefault() { viewModelScope.launch(Dispatchers.IO) { adminE2EByDefault = tryOrNull { - rawService.getElementWellknown(session.myUserId) + rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true } ?: true diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 0897e1c01d..0075be6e25 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -157,7 +157,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_HS_ADMIN_DISABLED_E2E_DEFAULT)?.isVisible = vectorActivity.getVectorComponent() .rawService() - .getElementWellknown(session.myUserId) + .getElementWellknown(session.sessionParams) ?.isE2EByDefault() == false } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceViewModelTask.kt b/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceViewModelTask.kt index f1731caf76..198e188723 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceViewModelTask.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/create/CreateSpaceViewModelTask.kt @@ -75,7 +75,7 @@ class CreateSpaceViewModelTask @Inject constructor( val childIds = mutableListOf() val e2eByDefault = tryOrNull { - rawService.getElementWellknown(session.myUserId) + rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true } ?: true diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt index 13944adfc8..95cf5fb461 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt @@ -81,7 +81,7 @@ class SpacePeopleViewModel @AssistedInject constructor( setState { copy(createAndInviteState = Loading()) } viewModelScope.launch(Dispatchers.IO) { - val adminE2EByDefault = rawService.getElementWellknown(session.myUserId) + val adminE2EByDefault = rawService.getElementWellknown(session.sessionParams) ?.isE2EByDefault() ?: true