refactor getRetrofitBucketForCreateRoom

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-03-25 11:53:05 +01:00
parent 3dfb00d5c4
commit 77fe2ad024
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
8 changed files with 42 additions and 55 deletions

View File

@ -186,12 +186,10 @@ class MainActivity : BaseActivity(), ActionBarProvider {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, 1))
val credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token)
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
currentUser?.baseUrl!!,
roomType,
null,
userId,
null
version = apiVersion,
baseUrl = currentUser?.baseUrl!!,
roomType = roomType,
invite = userId
)
ncApi.createRoom(

View File

@ -3168,12 +3168,10 @@ class ChatActivity :
val apiVersion =
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
conversationUser?.baseUrl!!,
"1",
null,
message?.user?.id?.substring(INVITE_LENGTH),
null
version = apiVersion,
baseUrl = conversationUser?.baseUrl!!,
roomType = "1",
invite = message?.user?.id?.substring(INVITE_LENGTH)
)
chatViewModel.createRoom(
credentials!!,
@ -3601,12 +3599,10 @@ class ChatActivity :
}
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
conversationUser?.baseUrl!!,
"1",
null,
userMentionClickEvent.userId,
null
version = apiVersion,
baseUrl = conversationUser?.baseUrl!!,
roomType = "1",
invite = userMentionClickEvent.userId
)
chatViewModel.createRoom(
@ -3713,12 +3709,11 @@ class ChatActivity :
val apiVersion =
ApiUtils.getConversationApiVersion(conversationUser!!, intArrayOf(ApiUtils.API_V4, 1))
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
conversationUser?.baseUrl!!,
ROOM_TYPE_ONE_TO_ONE,
ACTOR_TYPE,
userId,
null
version = apiVersion,
baseUrl = conversationUser?.baseUrl!!,
roomType = ROOM_TYPE_ONE_TO_ONE,
source = ACTOR_TYPE,
invite = userId
)
chatViewModel.createRoom(
credentials!!,

View File

@ -52,12 +52,12 @@ class ContactsRepositoryImpl @Inject constructor(
conversationName: String?
): RoomOverall {
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
_currentUser.baseUrl,
roomType,
sourceType,
userId,
conversationName
version = apiVersion,
baseUrl = _currentUser.baseUrl,
roomType = roomType,
source = sourceType,
invite = userId,
conversationName = conversationName
)
val response = ncApiCoroutines.createRoom(
credentials,

View File

@ -97,12 +97,10 @@ class ConversationCreationRepositoryImpl @Inject constructor(
override suspend fun createRoom(roomType: String, conversationName: String?): RoomOverall {
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
_currentUser.baseUrl,
roomType,
null,
null,
conversationName
version = apiVersion,
baseUrl = _currentUser.baseUrl,
roomType = roomType,
conversationName = conversationName
)
val response = ncApiCoroutines.createRoom(
credentials,

View File

@ -168,6 +168,7 @@ class ConversationInfoActivity :
if (startGroupChat) {
Snackbar.make(binding.root, "TODO: start group chat...", Snackbar.LENGTH_LONG).show()
viewModel.createRoom()
} else {
addParticipantsToConversation(participants)
}

View File

@ -120,6 +120,9 @@ class ConversationInfoViewModel @Inject constructor(
?.subscribe(GetRoomObserver())
}
fun createRoom() {
}
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
_getCapabilitiesViewState.value = GetCapabilitiesStartState

View File

@ -118,12 +118,10 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
val apiVersion =
ApiUtils.getConversationApiVersion(userModel, intArrayOf(ApiUtils.API_V4, 1))
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
userModel.baseUrl!!,
"1",
null,
userId,
null
version = apiVersion,
baseUrl = userModel.baseUrl!!,
roomType = "1",
invite = userId
)
val credentials = ApiUtils.getCredentials(userModel.username, userModel.token)
ncApi.createRoom(

View File

@ -298,25 +298,19 @@ object ApiUtils {
@Suppress("LongParameterList")
fun getRetrofitBucketForCreateRoom(
version: Int,
baseUrl: String?,
roomType: String,
source: String?,
invite: String?,
conversationName: String?
baseUrl: String? = null,
source: String? = null,
invite: String? = null,
conversationName: String? = null
): RetrofitBucket {
val retrofitBucket = RetrofitBucket()
retrofitBucket.url = getUrlForRooms(version, baseUrl)
val queryMap: MutableMap<String, String> = HashMap()
queryMap["roomType"] = roomType
if (invite != null) {
queryMap["invite"] = invite
}
if (source != null) {
queryMap["source"] = source
}
if (conversationName != null) {
queryMap["roomName"] = conversationName
}
invite?.let { queryMap["invite"] = it }
source?.let { queryMap["source"] = it }
conversationName?.let { queryMap["roomName"] = it }
retrofitBucket.queryMap = queryMap
return retrofitBucket
}