Implement renameRoom in ConversationInfoEditRepository
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
Родитель
8e20f5b0e4
Коммит
cedf1f09e9
|
@ -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<GenericOverall>
|
||||
|
||||
fun createConversation(
|
||||
roomName: String,
|
||||
conversationType: ConversationEnums.ConversationType?
|
||||
|
|
|
@ -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<GenericOverall> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ConversationModel>
|
||||
|
||||
fun deleteConversationAvatar(user: User, roomToken: String): Observable<ConversationModel>
|
||||
|
||||
suspend fun renameConversation(roomToken: String, roomNameNew: String): GenericOverall
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче