Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/noid/archive conversations handle old nc servers #4427

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
import com.nextcloud.talk.ui.dialog.DialogBanListFragment
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DateConstants
import com.nextcloud.talk.utils.DateUtils
Expand Down Expand Up @@ -403,10 +404,9 @@ class ConversationInfoActivity :
}
}

private fun webinaryRoomType(conversation: ConversationModel): Boolean {
return conversation.type == ConversationEnums.ConversationType.ROOM_GROUP_CALL ||
private fun webinaryRoomType(conversation: ConversationModel): Boolean =
conversation.type == ConversationEnums.ConversationType.ROOM_GROUP_CALL ||
conversation.type == ConversationEnums.ConversationType.ROOM_PUBLIC_CALL
}

private fun reconfigureLobbyTimerView(dateTime: Calendar? = null) {
val isChecked = binding.webinarInfoView.lobbySwitch.isChecked
Expand Down Expand Up @@ -792,8 +792,9 @@ class ConversationInfoActivity :
}
}

if (!CapabilitiesUtil.isArchiveConversationsAvailable(spreedCapabilities)) {
if (!hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ARCHIVE_CONVERSATIONS)) {
binding.archiveConversationBtn.visibility = GONE
binding.archiveConversationTextHint.visibility = GONE
}

binding.archiveConversationBtn.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import com.nextcloud.talk.conversationlist.ConversationsListActivity
import com.nextcloud.talk.databinding.DialogFilterConversationBinding
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.SpreedFeatures
import com.nextcloud.talk.utils.UserIdUtils
import javax.inject.Inject

Expand Down Expand Up @@ -104,7 +106,14 @@ class FilterConversationFragment : DialogFragment() {
private fun setUpChips() {
binding.unreadFilterChip.isChecked = filterState[UNREAD]!!
binding.mentionedFilterChip.isChecked = filterState[MENTION]!!
binding.archivedFilterChip.isChecked = filterState[ARCHIVE]!!

binding.archivedFilterChip.visibility = View.GONE
userManager.currentUser.blockingGet().capabilities?.spreedCapability?.let {
if (hasSpreedFeatureCapability(it, SpreedFeatures.ARCHIVE_CONVERSATIONS)) {
binding.archivedFilterChip.visibility = View.VISIBLE
binding.archivedFilterChip.isChecked = filterState[ARCHIVE]!!
}
}
}

private fun processSubmit() {
Expand Down
60 changes: 22 additions & 38 deletions app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum class SpreedFeatures(val value: String) {
DELETE_MESSAGES_UNLIMITED("delete-messages-unlimited"),
BAN_V1("ban-v1"),
EDIT_MESSAGES_NOTE_TO_SELF("edit-messages-note-to-self"),
ARCHIVE_CONVERSATIONS("archived-conversations")
ARCHIVE_CONVERSATIONS("archived-conversations-v2")
}

@Suppress("TooManyFunctions")
Expand Down Expand Up @@ -84,14 +84,11 @@ object CapabilitiesUtil {
//region CoreCapabilities

@JvmStatic
fun isLinkPreviewAvailable(user: User): Boolean {
return user.capabilities?.coreCapability?.referenceApi != null &&
fun isLinkPreviewAvailable(user: User): Boolean =
user.capabilities?.coreCapability?.referenceApi != null &&
user.capabilities?.coreCapability?.referenceApi == "true"
}

fun canGeneratePrettyURL(user: User): Boolean {
return user.capabilities?.coreCapability?.modRewriteWorking == true
}
fun canGeneratePrettyURL(user: User): Boolean = user.capabilities?.coreCapability?.modRewriteWorking == true

// endregion

Expand All @@ -105,9 +102,8 @@ object CapabilitiesUtil {
return false
}

fun isSharedItemsAvailable(spreedCapabilities: SpreedCapability): Boolean {
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA)
}
fun isSharedItemsAvailable(spreedCapabilities: SpreedCapability): Boolean =
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA)

fun getMessageMaxLength(spreedCapabilities: SpreedCapability): Int {
if (spreedCapabilities.config?.containsKey("chat") == true) {
Expand Down Expand Up @@ -157,16 +153,14 @@ object CapabilitiesUtil {
return "/Talk"
}

fun isConversationDescriptionEndpointAvailable(spreedCapabilities: SpreedCapability): Boolean {
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ROOM_DESCRIPTION)
}
fun isConversationDescriptionEndpointAvailable(spreedCapabilities: SpreedCapability): Boolean =
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ROOM_DESCRIPTION)

fun isUnifiedSearchAvailable(spreedCapabilities: SpreedCapability): Boolean {
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.UNIFIED_SEARCH)
}
fun isUnifiedSearchAvailable(spreedCapabilities: SpreedCapability): Boolean =
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.UNIFIED_SEARCH)

fun isAbleToCall(spreedCapabilities: SpreedCapability): Boolean {
return if (
fun isAbleToCall(spreedCapabilities: SpreedCapability): Boolean =
if (
spreedCapabilities.config?.containsKey("call") == true &&
spreedCapabilities.config!!["call"] != null &&
spreedCapabilities.config!!["call"]!!.containsKey("enabled")
Expand All @@ -176,7 +170,6 @@ object CapabilitiesUtil {
// older nextcloud versions without the capability can't disable the calls
true
}
}

fun isCallReactionsSupported(user: User?): Boolean {
if (user?.capabilities != null) {
Expand All @@ -188,12 +181,11 @@ object CapabilitiesUtil {
return false
}

fun isTranslationsSupported(spreedCapabilities: SpreedCapability): Boolean {
return spreedCapabilities.config?.containsKey("chat") == true &&
fun isTranslationsSupported(spreedCapabilities: SpreedCapability): Boolean =
spreedCapabilities.config?.containsKey("chat") == true &&
spreedCapabilities.config!!["chat"] != null &&
spreedCapabilities.config!!["chat"]!!.containsKey("has-translation-providers") &&
spreedCapabilities.config!!["chat"]!!["has-translation-providers"] == true
}

fun getRecordingConsentType(spreedCapabilities: SpreedCapability): Int {
if (
Expand All @@ -213,9 +205,8 @@ object CapabilitiesUtil {
return RECORDING_CONSENT_NOT_REQUIRED
}

fun isBanningAvailable(spreedCapabilities: SpreedCapability): Boolean {
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.BAN_V1)
}
fun isBanningAvailable(spreedCapabilities: SpreedCapability): Boolean =
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.BAN_V1)

// endregion

Expand Down Expand Up @@ -249,16 +240,11 @@ object CapabilitiesUtil {
return false
}

fun isFederationAvailable(user: User): Boolean {
return hasSpreedFeatureCapability(user.capabilities!!.spreedCapability!!, SpreedFeatures.FEDERATION_V1) &&
fun isFederationAvailable(user: User): Boolean =
hasSpreedFeatureCapability(user.capabilities!!.spreedCapability!!, SpreedFeatures.FEDERATION_V1) &&
user.capabilities!!.spreedCapability!!.config?.containsKey("federation") == true &&
user.capabilities!!.spreedCapability!!.config!!["federation"] != null &&
user.capabilities!!.spreedCapability!!.config!!["federation"]!!.containsKey("enabled")
}

fun isArchiveConversationsAvailable(spreedCapabilities: SpreedCapability): Boolean {
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ARCHIVE_CONVERSATIONS)
}

// endregion

Expand All @@ -275,20 +261,18 @@ object CapabilitiesUtil {

//region ProvisioningCapabilities

fun canEditScopes(user: User): Boolean {
return user.capabilities?.provisioningCapability?.accountPropertyScopesVersion != null &&
fun canEditScopes(user: User): Boolean =
user.capabilities?.provisioningCapability?.accountPropertyScopesVersion != null &&
user.capabilities!!.provisioningCapability!!.accountPropertyScopesVersion!! > 1
}

// endregion

//region UserStatusCapabilities

@JvmStatic
fun isUserStatusAvailable(user: User): Boolean {
return user.capabilities?.userStatusCapability?.enabled == true &&
fun isUserStatusAvailable(user: User): Boolean =
user.capabilities?.userStatusCapability?.enabled == true &&
user.capabilities?.userStatusCapability?.supportsEmoji == true
}

// endregion

Expand Down
Loading