diff --git a/app/src/main/java/com/nextcloud/talk/data/user/model/User.kt b/app/src/main/java/com/nextcloud/talk/data/user/model/User.kt index 1cbac33ea..31491e1ab 100644 --- a/app/src/main/java/com/nextcloud/talk/data/user/model/User.kt +++ b/app/src/main/java/com/nextcloud/talk/data/user/model/User.kt @@ -44,7 +44,7 @@ data class User( ) : Parcelable { fun getMaxMessageLength(): Int { - return capabilities?.spreedCapability?.config?.get("chat")?.get("max-length")?.toInt() + return (capabilities?.spreedCapability?.config?.get("chat")?.get("max-length") as? String)?.toInt() ?: DEFAULT_CHAT_MESSAGE_LENGTH } @@ -53,7 +53,7 @@ data class User( } fun canUserCreateGroupConversations(): Boolean { - val canCreateValue = capabilities?.spreedCapability?.config?.get("conversations")?.get("can-create") + val canCreateValue = capabilities?.spreedCapability?.config?.get("conversations")?.get("can-create") as? String canCreateValue?.let { return it.toBoolean() } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/capabilities/SpreedCapability.kt b/app/src/main/java/com/nextcloud/talk/models/json/capabilities/SpreedCapability.kt index 8e3a8d950..df50bbb77 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/capabilities/SpreedCapability.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/capabilities/SpreedCapability.kt @@ -24,7 +24,10 @@ package com.nextcloud.talk.models.json.capabilities import android.os.Parcelable import com.bluelinelabs.logansquare.annotation.JsonField import com.bluelinelabs.logansquare.annotation.JsonObject + import kotlinx.parcelize.Parcelize +import kotlinx.parcelize.RawValue +import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable @Parcelize @@ -34,7 +37,8 @@ data class SpreedCapability( @JsonField(name = ["features"]) var features: List?, @JsonField(name = ["config"]) - var config: HashMap>? + var config: HashMap>? ) : Parcelable { // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' constructor() : this(null, null) diff --git a/app/src/main/java/com/nextcloud/talk/utils/database/user/CapabilitiesUtilNew.kt b/app/src/main/java/com/nextcloud/talk/utils/database/user/CapabilitiesUtilNew.kt index 97a30404e..081d37d9c 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/database/user/CapabilitiesUtilNew.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/database/user/CapabilitiesUtilNew.kt @@ -67,8 +67,8 @@ object CapabilitiesUtilNew { if (user?.capabilities?.spreedCapability?.config?.containsKey("chat") == true) { val chatConfigHashMap = user.capabilities!!.spreedCapability!!.config!!["chat"] if (chatConfigHashMap?.containsKey("max-length") == true) { - val chatSize = chatConfigHashMap["max-length"]!!.toInt() - return if (chatSize > 0) { + val chatSize = (chatConfigHashMap["max-length"]!! as? String)?.toInt() + return if (chatSize != null && chatSize > 0) { chatSize } else { DEFAULT_CHAT_SIZE @@ -85,7 +85,7 @@ object CapabilitiesUtilNew { fun isReadStatusAvailable(user: User): Boolean { if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) { - val map: Map? = user.capabilities!!.spreedCapability!!.config!!["chat"] + val map: Map? = user.capabilities!!.spreedCapability!!.config!!["chat"] return map != null && map.containsKey("read-privacy") } return false @@ -95,7 +95,7 @@ object CapabilitiesUtilNew { if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) { val map = user.capabilities!!.spreedCapability!!.config!!["chat"] if (map?.containsKey("read-privacy") == true) { - return map["read-privacy"]!!.toInt() == 1 + return (map["read-privacy"]!! as? String)?.toInt() == 1 } } @@ -107,9 +107,9 @@ object CapabilitiesUtilNew { if (hasSpreedFeatureCapability(user, "recording-v1") && user.capabilities?.spreedCapability?.config?.containsKey("call") == true ) { - val map: Map? = user.capabilities!!.spreedCapability!!.config!!["call"] + val map: Map? = user.capabilities!!.spreedCapability!!.config!!["call"] if (map != null && map.containsKey("recording")) { - return map["recording"].toBoolean() + return (map["recording"] as? String).toBoolean() } } return false @@ -126,7 +126,7 @@ object CapabilitiesUtilNew { if (user.capabilities?.spreedCapability?.config?.containsKey("attachments") == true) { val map = user.capabilities!!.spreedCapability!!.config!!["attachments"] if (map?.containsKey("folder") == true) { - return map["folder"] + return map["folder"] as? String } } return "/Talk" @@ -157,7 +157,7 @@ object CapabilitiesUtilNew { capabilities.spreedCapability!!.config!!["call"] != null && capabilities.spreedCapability!!.config!!["call"]!!.containsKey("enabled") ) { - java.lang.Boolean.parseBoolean(capabilities.spreedCapability!!.config!!["call"]!!["enabled"]) + java.lang.Boolean.parseBoolean(capabilities.spreedCapability!!.config!!["call"]!!["enabled"] as? String) } else { // older nextcloud versions without the capability can't disable the calls true