diff --git a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt index 70c50aa64..96580c646 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt @@ -8,13 +8,10 @@ package com.nextcloud.talk.conversation.repository import com.nextcloud.talk.models.json.conversations.ConversationEnums import com.nextcloud.talk.models.json.conversations.RoomOverall -import com.nextcloud.talk.models.json.generic.GenericOverall import io.reactivex.Observable interface ConversationRepository { - fun renameConversation(roomToken: String, roomNameNew: String): Observable - fun createConversation( roomName: String, conversationType: ConversationEnums.ConversationType? diff --git a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt index f5dae7059..8f344f5e5 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt @@ -11,7 +11,6 @@ import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.models.RetrofitBucket import com.nextcloud.talk.models.json.conversations.ConversationEnums import com.nextcloud.talk.models.json.conversations.RoomOverall -import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew import io.reactivex.Observable @@ -24,22 +23,7 @@ class ConversationRepositoryImpl(private val ncApi: NcApi, currentUserProvider: val currentUser: User = currentUserProvider.currentUser.blockingGet() val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)!! - override fun renameConversation(roomToken: String, roomNameNew: String): Observable { - val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) - return ncApi.renameRoom( - credentials, - ApiUtils.getUrlForRoom( - apiVersion, - currentUser.baseUrl!!, - roomToken - ), - roomNameNew - ) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .retry(API_RETRIES) - } override fun createConversation( roomName: String, @@ -76,6 +60,5 @@ class ConversationRepositoryImpl(private val ncApi: NcApi, currentUserProvider: companion object { private const val ROOM_TYPE_PUBLIC = "3" private const val ROOM_TYPE_GROUP = "2" - const val API_RETRIES: Long = 3 } } diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepository.kt b/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepository.kt index 83628ca7c..7f06b7a2b 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepository.kt @@ -8,6 +8,7 @@ package com.nextcloud.talk.conversationinfoedit.data import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.models.domain.ConversationModel +import com.nextcloud.talk.models.json.generic.GenericOverall import io.reactivex.Observable import java.io.File @@ -16,4 +17,6 @@ interface ConversationInfoEditRepository { fun uploadConversationAvatar(user: User, file: File, roomToken: String): Observable fun deleteConversationAvatar(user: User, roomToken: String): Observable + + suspend fun renameConversation(roomToken: String, roomNameNew: String): GenericOverall } diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepositoryImpl.kt index 8ed719a4c..4a02f2667 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfoedit/data/ConversationInfoEditRepositoryImpl.kt @@ -7,8 +7,10 @@ package com.nextcloud.talk.conversationinfoedit.data import com.nextcloud.talk.api.NcApi +import com.nextcloud.talk.api.NcApiCoroutines import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.models.domain.ConversationModel +import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.Mimetype import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew @@ -18,7 +20,9 @@ import okhttp3.MultipartBody import okhttp3.RequestBody.Companion.asRequestBody import java.io.File -class ConversationInfoEditRepositoryImpl(private val ncApi: NcApi, currentUserProvider: CurrentUserProviderNew) : +class ConversationInfoEditRepositoryImpl(private val ncApi: NcApi, + private val ncApiCoroutines: NcApiCoroutines, + currentUserProvider: CurrentUserProviderNew) : ConversationInfoEditRepository { val currentUser: User = currentUserProvider.currentUser.blockingGet() @@ -53,4 +57,18 @@ class ConversationInfoEditRepositoryImpl(private val ncApi: NcApi, currentUserPr ApiUtils.getUrlForConversationAvatar(1, user.baseUrl!!, roomToken) ).map { ConversationModel.mapToConversationModel(it.ocs?.data!!, user) } } + + override suspend fun renameConversation(roomToken: String, newRoomName: String): GenericOverall { + val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) + + return ncApiCoroutines.renameRoom( + credentials, + ApiUtils.getUrlForRoom( + apiVersion, + currentUser.baseUrl!!, + roomToken + ), + newRoomName + ) + } }