mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
Merge pull request #2976 from nextcloud/bugfix/noid/fixCapabilityParsing
Fix call feature parsing
This commit is contained in:
commit
7ed1c95cb8
2 changed files with 6 additions and 27 deletions
|
@ -43,30 +43,9 @@ data class User(
|
||||||
var scheduledForDeletion: Boolean = FALSE
|
var scheduledForDeletion: Boolean = FALSE
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
fun getMaxMessageLength(): Int {
|
|
||||||
return (capabilities?.spreedCapability?.config?.get("chat")?.get("max-length") as? String)?.toInt()
|
|
||||||
?: DEFAULT_CHAT_MESSAGE_LENGTH
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAttachmentsConfig(key: String): Any? {
|
|
||||||
return capabilities?.spreedCapability?.config?.get("attachments")?.get(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun canUserCreateGroupConversations(): Boolean {
|
|
||||||
val canCreateValue = capabilities?.spreedCapability?.config?.get("conversations")?.get("can-create") as? String
|
|
||||||
canCreateValue?.let {
|
|
||||||
return it.toBoolean()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCredentials(): String = ApiUtils.getCredentials(username, token)
|
fun getCredentials(): String = ApiUtils.getCredentials(username, token)
|
||||||
|
|
||||||
fun hasSpreedFeatureCapability(capabilityName: String): Boolean {
|
fun hasSpreedFeatureCapability(capabilityName: String): Boolean {
|
||||||
return capabilities?.spreedCapability?.features?.contains(capabilityName) ?: false
|
return capabilities?.spreedCapability?.features?.contains(capabilityName) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val DEFAULT_CHAT_MESSAGE_LENGTH: Int = 1000
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"]!! as? String)?.toInt()
|
val chatSize = (chatConfigHashMap["max-length"]!!.toString()).toInt()
|
||||||
return if (chatSize != null && chatSize > 0) {
|
return if (chatSize > 0) {
|
||||||
chatSize
|
chatSize
|
||||||
} else {
|
} else {
|
||||||
DEFAULT_CHAT_SIZE
|
DEFAULT_CHAT_SIZE
|
||||||
|
@ -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"]!! as? String)?.toInt() == 1
|
return (map["read-privacy"]!!.toString()).toInt() == 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ object CapabilitiesUtilNew {
|
||||||
) {
|
) {
|
||||||
val map: Map<String, Any>? = 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"] as? String).toBoolean()
|
return (map["recording"].toString()).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"] as? String
|
return map["folder"].toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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"] as? String)
|
java.lang.Boolean.parseBoolean(capabilities.spreedCapability!!.config!!["call"]!!["enabled"].toString())
|
||||||
} 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