add unbind-conversation capability

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-05-20 09:00:10 +02:00 committed by Marcel Hibbe
parent 01b80a0753
commit 1670ff181f
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 22 additions and 8 deletions

View File

@ -169,6 +169,7 @@ import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.AudioUtils
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.CapabilitiesUtil.retentionOfEventRooms
import com.nextcloud.talk.utils.CapabilitiesUtil.retentionOfInstantMeetingRoom
import com.nextcloud.talk.utils.CapabilitiesUtil.retentionOfSIPRoom
@ -668,7 +669,11 @@ class ChatActivity :
}
}
if (currentConversation?.objectType == ConversationEnums.ObjectType.EVENT) {
if (currentConversation?.objectType == ConversationEnums.ObjectType.EVENT && hasSpreedFeatureCapability(
conversationUser?.capabilities!!.spreedCapability!!,
SpreedFeatures.UNBIND_CONVERSATION
)
) {
val eventEndTimeStamp = currentConversation?.objectId?.split("#")[1]?.toLong()
val currentTimeStamp = (System.currentTimeMillis() / 1000).toLong()
val retentionPeriod = retentionOfEventRooms(spreedCapabilities)
@ -678,7 +683,11 @@ class ChatActivity :
}
}
if (currentConversation?.objectType == ConversationEnums.ObjectType.PHONE) {
if (currentConversation?.objectType == ConversationEnums.ObjectType.PHONE && hasSpreedFeatureCapability(
conversationUser?.capabilities!!.spreedCapability!!,
SpreedFeatures.UNBIND_CONVERSATION
)
) {
val retentionPeriod = retentionOfSIPRoom(spreedCapabilities)
val systemMessage = currentConversation?.lastMessage?.systemMessageType
if (retentionPeriod != 0 && (
@ -690,7 +699,11 @@ class ChatActivity :
}
}
if (currentConversation?.objectType == ConversationEnums.ObjectType.INSTANT_MEETING) {
if (currentConversation?.objectType == ConversationEnums.ObjectType.INSTANT_MEETING && hasSpreedFeatureCapability(
conversationUser?.capabilities!!.spreedCapability!!,
SpreedFeatures.UNBIND_CONVERSATION
)
) {
val retentionPeriod = retentionOfInstantMeetingRoom(spreedCapabilities)
val systemMessage = currentConversation?.lastMessage?.systemMessageType
if (retentionPeriod != 0 && (
@ -1232,7 +1245,7 @@ class ChatActivity :
}
}
fun deleteConversationDialog(context: Context) {
fun deleteConversationDialog(context: Context) {
val dialogBuilder = MaterialAlertDialogBuilder(context)
.setIcon(
viewThemeUtils.dialog

View File

@ -808,7 +808,7 @@ class ChatViewModel @Inject constructor(
}
}
fun unbindRoom(credentials: String, baseUrl: String, roomToken: String) {
fun unbindRoom(credentials: String, baseUrl: String, roomToken: String) {
viewModelScope.launch {
try {
val response = chatNetworkDataSource.unbindRoom(credentials, baseUrl, roomToken)

View File

@ -449,7 +449,7 @@ object ApiUtils {
return "$baseUrl$OCS_API_VERSION/cloud/users/search/by-phone"
}
fun getUrlForUnbindingRoom(baseUrl: String, roomToken: String): String {
fun getUrlForUnbindingRoom(baseUrl: String, roomToken: String): String {
return "$baseUrl/ocs/v2.php/apps/spreed/api/v4/room/$roomToken/object"
}

View File

@ -57,7 +57,8 @@ enum class SpreedFeatures(val value: String) {
BAN_V1("ban-v1"),
EDIT_MESSAGES_NOTE_TO_SELF("edit-messages-note-to-self"),
ARCHIVE_CONVERSATIONS("archived-conversations-v2"),
CONVERSATION_CREATION_ALL("conversation-creation-all")
CONVERSATION_CREATION_ALL("conversation-creation-all"),
UNBIND_CONVERSATION("unbind-conversation")
}
@Suppress("TooManyFunctions")

View File

@ -521,7 +521,7 @@ How to translate with transifex:
leaked to other services</string>
<string name="startCallForbidden">You are not allowed to start a call</string>
<string name="nc_last_moderator_leaving_room_warning">You need to promote a new moderator before you can leave the conversation</string>
<string name="nc_room_retention">Room was retained successfully</string>
<string name="nc_room_retention">Room is retained successfully</string>
<string name="share">Share</string>
<string name="send_to">Send to</string>