mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
refactor getRetrofitBucketForCreateRoom
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
3dfb00d5c4
commit
77fe2ad024
@ -186,12 +186,10 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, 1))
|
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
val credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token)
|
val credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token)
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
currentUser?.baseUrl!!,
|
baseUrl = currentUser?.baseUrl!!,
|
||||||
roomType,
|
roomType = roomType,
|
||||||
null,
|
invite = userId
|
||||||
userId,
|
|
||||||
null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ncApi.createRoom(
|
ncApi.createRoom(
|
||||||
|
@ -3168,12 +3168,10 @@ class ChatActivity :
|
|||||||
val apiVersion =
|
val apiVersion =
|
||||||
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
conversationUser?.baseUrl!!,
|
baseUrl = conversationUser?.baseUrl!!,
|
||||||
"1",
|
roomType = "1",
|
||||||
null,
|
invite = message?.user?.id?.substring(INVITE_LENGTH)
|
||||||
message?.user?.id?.substring(INVITE_LENGTH),
|
|
||||||
null
|
|
||||||
)
|
)
|
||||||
chatViewModel.createRoom(
|
chatViewModel.createRoom(
|
||||||
credentials!!,
|
credentials!!,
|
||||||
@ -3601,12 +3599,10 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
conversationUser?.baseUrl!!,
|
baseUrl = conversationUser?.baseUrl!!,
|
||||||
"1",
|
roomType = "1",
|
||||||
null,
|
invite = userMentionClickEvent.userId
|
||||||
userMentionClickEvent.userId,
|
|
||||||
null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
chatViewModel.createRoom(
|
chatViewModel.createRoom(
|
||||||
@ -3713,12 +3709,11 @@ class ChatActivity :
|
|||||||
val apiVersion =
|
val apiVersion =
|
||||||
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
conversationUser?.baseUrl!!,
|
baseUrl = conversationUser?.baseUrl!!,
|
||||||
ROOM_TYPE_ONE_TO_ONE,
|
roomType = ROOM_TYPE_ONE_TO_ONE,
|
||||||
ACTOR_TYPE,
|
source = ACTOR_TYPE,
|
||||||
userId,
|
invite = userId
|
||||||
null
|
|
||||||
)
|
)
|
||||||
chatViewModel.createRoom(
|
chatViewModel.createRoom(
|
||||||
credentials!!,
|
credentials!!,
|
||||||
|
@ -52,12 +52,12 @@ class ContactsRepositoryImpl @Inject constructor(
|
|||||||
conversationName: String?
|
conversationName: String?
|
||||||
): RoomOverall {
|
): RoomOverall {
|
||||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
_currentUser.baseUrl,
|
baseUrl = _currentUser.baseUrl,
|
||||||
roomType,
|
roomType = roomType,
|
||||||
sourceType,
|
source = sourceType,
|
||||||
userId,
|
invite = userId,
|
||||||
conversationName
|
conversationName = conversationName
|
||||||
)
|
)
|
||||||
val response = ncApiCoroutines.createRoom(
|
val response = ncApiCoroutines.createRoom(
|
||||||
credentials,
|
credentials,
|
||||||
|
@ -97,12 +97,10 @@ class ConversationCreationRepositoryImpl @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun createRoom(roomType: String, conversationName: String?): RoomOverall {
|
override suspend fun createRoom(roomType: String, conversationName: String?): RoomOverall {
|
||||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
_currentUser.baseUrl,
|
baseUrl = _currentUser.baseUrl,
|
||||||
roomType,
|
roomType = roomType,
|
||||||
null,
|
conversationName = conversationName
|
||||||
null,
|
|
||||||
conversationName
|
|
||||||
)
|
)
|
||||||
val response = ncApiCoroutines.createRoom(
|
val response = ncApiCoroutines.createRoom(
|
||||||
credentials,
|
credentials,
|
||||||
|
@ -168,6 +168,7 @@ class ConversationInfoActivity :
|
|||||||
|
|
||||||
if (startGroupChat) {
|
if (startGroupChat) {
|
||||||
Snackbar.make(binding.root, "TODO: start group chat...", Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.root, "TODO: start group chat...", Snackbar.LENGTH_LONG).show()
|
||||||
|
viewModel.createRoom()
|
||||||
} else {
|
} else {
|
||||||
addParticipantsToConversation(participants)
|
addParticipantsToConversation(participants)
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,9 @@ class ConversationInfoViewModel @Inject constructor(
|
|||||||
?.subscribe(GetRoomObserver())
|
?.subscribe(GetRoomObserver())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createRoom() {
|
||||||
|
}
|
||||||
|
|
||||||
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
||||||
_getCapabilitiesViewState.value = GetCapabilitiesStartState
|
_getCapabilitiesViewState.value = GetCapabilitiesStartState
|
||||||
|
|
||||||
|
@ -118,12 +118,10 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
|
|||||||
val apiVersion =
|
val apiVersion =
|
||||||
ApiUtils.getConversationApiVersion(userModel, intArrayOf(ApiUtils.API_V4, 1))
|
ApiUtils.getConversationApiVersion(userModel, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion,
|
version = apiVersion,
|
||||||
userModel.baseUrl!!,
|
baseUrl = userModel.baseUrl!!,
|
||||||
"1",
|
roomType = "1",
|
||||||
null,
|
invite = userId
|
||||||
userId,
|
|
||||||
null
|
|
||||||
)
|
)
|
||||||
val credentials = ApiUtils.getCredentials(userModel.username, userModel.token)
|
val credentials = ApiUtils.getCredentials(userModel.username, userModel.token)
|
||||||
ncApi.createRoom(
|
ncApi.createRoom(
|
||||||
|
@ -298,25 +298,19 @@ object ApiUtils {
|
|||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
fun getRetrofitBucketForCreateRoom(
|
fun getRetrofitBucketForCreateRoom(
|
||||||
version: Int,
|
version: Int,
|
||||||
baseUrl: String?,
|
|
||||||
roomType: String,
|
roomType: String,
|
||||||
source: String?,
|
baseUrl: String? = null,
|
||||||
invite: String?,
|
source: String? = null,
|
||||||
conversationName: String?
|
invite: String? = null,
|
||||||
|
conversationName: String? = null
|
||||||
): RetrofitBucket {
|
): RetrofitBucket {
|
||||||
val retrofitBucket = RetrofitBucket()
|
val retrofitBucket = RetrofitBucket()
|
||||||
retrofitBucket.url = getUrlForRooms(version, baseUrl)
|
retrofitBucket.url = getUrlForRooms(version, baseUrl)
|
||||||
val queryMap: MutableMap<String, String> = HashMap()
|
val queryMap: MutableMap<String, String> = HashMap()
|
||||||
queryMap["roomType"] = roomType
|
queryMap["roomType"] = roomType
|
||||||
if (invite != null) {
|
invite?.let { queryMap["invite"] = it }
|
||||||
queryMap["invite"] = invite
|
source?.let { queryMap["source"] = it }
|
||||||
}
|
conversationName?.let { queryMap["roomName"] = it }
|
||||||
if (source != null) {
|
|
||||||
queryMap["source"] = source
|
|
||||||
}
|
|
||||||
if (conversationName != null) {
|
|
||||||
queryMap["roomName"] = conversationName
|
|
||||||
}
|
|
||||||
retrofitBucket.queryMap = queryMap
|
retrofitBucket.queryMap = queryMap
|
||||||
return retrofitBucket
|
return retrofitBucket
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user