Merge pull request #5036 from nextcloud/backport/5035/stable-21.1

[stable-21.1] Profile data in ConversationInfo: catch http 405 if endpoint is not available
This commit is contained in:
Marcel Hibbe 2025-06-04 12:03:32 +00:00 committed by GitHub
commit 26aece63fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -319,14 +319,19 @@ class ConversationInfoViewModel @Inject constructor(
}
}
@Suppress("Detekt.TooGenericExceptionCaught")
fun getProfileData(user: User, userId: String) {
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
viewModelScope.launch {
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
if (profile != null) {
_getProfileViewState.value = GetProfileSuccessState(profile)
} else {
_getProfileViewState.value = GetProfileErrorState
try {
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
if (profile != null) {
_getProfileViewState.value = GetProfileSuccessState(profile)
} else {
_getProfileViewState.value = GetProfileErrorState
}
} catch (e: Exception) {
Log.w(TAG, "Failed to get profile data (if not supported there wil be http405)", e)
}
}
}