mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 17:38:55 +03:00
Merge pull request #2963 from nextcloud/bugfix/2962/adaptJsonParsingToNewCapabiliesStructure
Handle new capabilities json structure
This commit is contained in:
commit
c3b91bd908
3 changed files with 15 additions and 11 deletions
|
@ -44,7 +44,7 @@ data class User(
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
fun getMaxMessageLength(): Int {
|
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
|
?: DEFAULT_CHAT_MESSAGE_LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ data class User(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canUserCreateGroupConversations(): Boolean {
|
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 {
|
canCreateValue?.let {
|
||||||
return it.toBoolean()
|
return it.toBoolean()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,10 @@ package com.nextcloud.talk.models.json.capabilities
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import kotlinx.parcelize.RawValue
|
||||||
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
|
@ -34,7 +37,8 @@ data class SpreedCapability(
|
||||||
@JsonField(name = ["features"])
|
@JsonField(name = ["features"])
|
||||||
var features: List<String>?,
|
var features: List<String>?,
|
||||||
@JsonField(name = ["config"])
|
@JsonField(name = ["config"])
|
||||||
var config: HashMap<String, HashMap<String, String>>?
|
var config: HashMap<String, HashMap<String, @RawValue @Contextual
|
||||||
|
Any>>?
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null, null)
|
constructor() : this(null, null)
|
||||||
|
|
|
@ -67,8 +67,8 @@ object CapabilitiesUtilNew {
|
||||||
if (user?.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
if (user?.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
||||||
val chatConfigHashMap = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
val chatConfigHashMap = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
||||||
if (chatConfigHashMap?.containsKey("max-length") == true) {
|
if (chatConfigHashMap?.containsKey("max-length") == true) {
|
||||||
val chatSize = chatConfigHashMap["max-length"]!!.toInt()
|
val chatSize = (chatConfigHashMap["max-length"]!! as? String)?.toInt()
|
||||||
return if (chatSize > 0) {
|
return if (chatSize != null && chatSize > 0) {
|
||||||
chatSize
|
chatSize
|
||||||
} else {
|
} else {
|
||||||
DEFAULT_CHAT_SIZE
|
DEFAULT_CHAT_SIZE
|
||||||
|
@ -85,7 +85,7 @@ object CapabilitiesUtilNew {
|
||||||
|
|
||||||
fun isReadStatusAvailable(user: User): Boolean {
|
fun isReadStatusAvailable(user: User): Boolean {
|
||||||
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
||||||
val map: Map<String, String>? = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
val map: Map<String, Any>? = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
||||||
return map != null && map.containsKey("read-privacy")
|
return map != null && map.containsKey("read-privacy")
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -95,7 +95,7 @@ object CapabilitiesUtilNew {
|
||||||
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
||||||
val map = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
val map = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
||||||
if (map?.containsKey("read-privacy") == true) {
|
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") &&
|
if (hasSpreedFeatureCapability(user, "recording-v1") &&
|
||||||
user.capabilities?.spreedCapability?.config?.containsKey("call") == true
|
user.capabilities?.spreedCapability?.config?.containsKey("call") == true
|
||||||
) {
|
) {
|
||||||
val map: Map<String, String>? = user.capabilities!!.spreedCapability!!.config!!["call"]
|
val map: Map<String, Any>? = user.capabilities!!.spreedCapability!!.config!!["call"]
|
||||||
if (map != null && map.containsKey("recording")) {
|
if (map != null && map.containsKey("recording")) {
|
||||||
return map["recording"].toBoolean()
|
return (map["recording"] as? String).toBoolean()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -126,7 +126,7 @@ object CapabilitiesUtilNew {
|
||||||
if (user.capabilities?.spreedCapability?.config?.containsKey("attachments") == true) {
|
if (user.capabilities?.spreedCapability?.config?.containsKey("attachments") == true) {
|
||||||
val map = user.capabilities!!.spreedCapability!!.config!!["attachments"]
|
val map = user.capabilities!!.spreedCapability!!.config!!["attachments"]
|
||||||
if (map?.containsKey("folder") == true) {
|
if (map?.containsKey("folder") == true) {
|
||||||
return map["folder"]
|
return map["folder"] as? String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "/Talk"
|
return "/Talk"
|
||||||
|
@ -157,7 +157,7 @@ object CapabilitiesUtilNew {
|
||||||
capabilities.spreedCapability!!.config!!["call"] != null &&
|
capabilities.spreedCapability!!.config!!["call"] != null &&
|
||||||
capabilities.spreedCapability!!.config!!["call"]!!.containsKey("enabled")
|
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 {
|
} else {
|
||||||
// older nextcloud versions without the capability can't disable the calls
|
// older nextcloud versions without the capability can't disable the calls
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in a new issue