mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Merge pull request #4871 from nextcloud/bugfix/4869/avoidNoSupportedApiException
add hotfix to avoid NoSupportedApiException in ContactsRepositoryImpl
This commit is contained in:
commit
65e5be4798
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.contacts
|
package com.nextcloud.talk.contacts
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.nextcloud.talk.api.NcApiCoroutines
|
import com.nextcloud.talk.api.NcApiCoroutines
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.models.RetrofitBucket
|
import com.nextcloud.talk.models.RetrofitBucket
|
||||||
@ -14,6 +15,7 @@ import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
|
|||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.ContactUtils
|
import com.nextcloud.talk.utils.ContactUtils
|
||||||
|
import com.nextcloud.talk.utils.NoSupportedApiException
|
||||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -25,7 +27,6 @@ class ContactsRepositoryImpl @Inject constructor(
|
|||||||
private val _currentUser = currentUserProvider.currentUser.blockingGet()
|
private val _currentUser = currentUserProvider.currentUser.blockingGet()
|
||||||
val currentUser: User = _currentUser
|
val currentUser: User = _currentUser
|
||||||
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token)
|
val credentials = ApiUtils.getCredentials(_currentUser.username, _currentUser.token)
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(_currentUser, intArrayOf(ApiUtils.API_V4, 1))
|
|
||||||
|
|
||||||
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
|
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
|
||||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForContactsSearchFor14(
|
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForContactsSearchFor14(
|
||||||
@ -51,6 +52,24 @@ class ContactsRepositoryImpl @Inject constructor(
|
|||||||
userId: String,
|
userId: String,
|
||||||
conversationName: String?
|
conversationName: String?
|
||||||
): RoomOverall {
|
): RoomOverall {
|
||||||
|
val apiVersion =
|
||||||
|
try {
|
||||||
|
ApiUtils.getConversationApiVersion(_currentUser, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
|
} catch (e: NoSupportedApiException) {
|
||||||
|
// There were crash reports for:
|
||||||
|
// Exception java.lang.RuntimeException:
|
||||||
|
// ...
|
||||||
|
// Caused by com.nextcloud.talk.utils.NoSupportedApiException:
|
||||||
|
// at com.nextcloud.talk.utils.ApiUtils.getConversationApiVersion (ApiUtils.kt:134)
|
||||||
|
// at com.nextcloud.talk.contacts.ContactsRepositoryImpl.<init> (ContactsRepositoryImpl.kt:28)
|
||||||
|
//
|
||||||
|
// This could happen because of missing capabilities for user and should be fixed.
|
||||||
|
// As a fallback, API v4 is guessed
|
||||||
|
|
||||||
|
Log.e(TAG, "Failed to get an Api version for conversation.", e)
|
||||||
|
ApiUtils.API_V4
|
||||||
|
}
|
||||||
|
|
||||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
apiVersion,
|
||||||
_currentUser.baseUrl,
|
_currentUser.baseUrl,
|
||||||
@ -74,4 +93,8 @@ class ContactsRepositoryImpl @Inject constructor(
|
|||||||
requestBigSize
|
requestBigSize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG = ContactsRepositoryImpl::class.simpleName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
package com.nextcloud.talk.data.user.model
|
package com.nextcloud.talk.data.user.model
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import android.util.Log
|
||||||
import com.nextcloud.talk.models.ExternalSignalingServer
|
import com.nextcloud.talk.models.ExternalSignalingServer
|
||||||
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
||||||
import com.nextcloud.talk.models.json.capabilities.ServerVersion
|
import com.nextcloud.talk.models.json.capabilities.ServerVersion
|
||||||
@ -37,6 +38,13 @@ data class User(
|
|||||||
fun getCredentials(): String = ApiUtils.getCredentials(username, token)!!
|
fun getCredentials(): String = ApiUtils.getCredentials(username, token)!!
|
||||||
|
|
||||||
fun hasSpreedFeatureCapability(capabilityName: String): Boolean {
|
fun hasSpreedFeatureCapability(capabilityName: String): Boolean {
|
||||||
|
if (capabilities == null) {
|
||||||
|
Log.e(TAG, "Capabilities are null in hasSpreedFeatureCapability. false is returned for capability check")
|
||||||
|
}
|
||||||
return capabilities?.spreedCapability?.features?.contains(capabilityName) ?: false
|
return capabilities?.spreedCapability?.features?.contains(capabilityName) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG = User::class.simpleName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user