Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ownCloud admins and users.
* Enhancement - Update test in GitHub Actions: [#4663](https://github.com/owncloud/android/pull/4663)
* Enhancement - New workflow to generate a build from "latest" tag on demand: [#4681](https://github.com/owncloud/android/pull/4681)
* Enhancement - Make Update test more robust: [#4690](https://github.com/owncloud/android/pull/4690)
* Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698)

## Details

Expand Down Expand Up @@ -156,6 +157,13 @@ ownCloud admins and users.

https://github.com/owncloud/android/pull/4690

* Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698)

A new field representing the user role has been added to the space model and to
the spaces table in the database.

https://github.com/owncloud/android/pull/4698

# Changelog for ownCloud Android Client [4.6.2] (2025-08-13)

The following sections list the changes in ownCloud Android Client 4.6.2 relevant to
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/4698
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add user role to spaces

A new field representing the user role has been added to the space model and to the spaces table in the database.

https://github.com/owncloud/android/pull/4698
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import com.owncloud.android.domain.transfers.usecases.UpdatePendingUploadsPathUs
import com.owncloud.android.domain.user.usecases.GetStoredQuotaUseCase
import com.owncloud.android.domain.user.usecases.GetStoredQuotaAsStreamUseCase
import com.owncloud.android.domain.user.usecases.GetUserAvatarAsyncUseCase
import com.owncloud.android.domain.user.usecases.GetUserGroupsAsyncUseCase
import com.owncloud.android.domain.user.usecases.GetUserInfoAsyncUseCase
import com.owncloud.android.domain.user.usecases.GetUserQuotasUseCase
import com.owncloud.android.domain.user.usecases.GetUserQuotasAsStreamUseCase
Expand Down Expand Up @@ -269,6 +270,7 @@ val useCaseModule = module {
factoryOf(::GetStoredQuotaAsStreamUseCase)
factoryOf(::GetStoredQuotaUseCase)
factoryOf(::GetUserAvatarAsyncUseCase)
factoryOf(::GetUserGroupsAsyncUseCase)
factoryOf(::GetUserIdAsyncUseCase)
factoryOf(::GetUserInfoAsyncUseCase)
factoryOf(::GetUserPermissionsAsyncUseCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ data class RootResponse(
val id: String,
val webDavUrl: String,
val deleted: DeleteResponse?,
val permissions: List<PermissionsResponse>?
)

@JsonClass(generateAdapter = true)
Expand Down Expand Up @@ -97,3 +98,20 @@ data class DeleteResponse(
data class SpecialFolderResponse(
val name: String
)

@JsonClass(generateAdapter = true)
data class PermissionsResponse(
val grantedToV2: GrantedToV2Response,
val roles: List<String>
)

@JsonClass(generateAdapter = true)
data class GrantedToV2Response(
val user: UserResponse?,
val group: GroupResponse?
)

@JsonClass(generateAdapter = true)
data class GroupResponse(
val id: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* ownCloud Android client application
*
* @author Jorge Aguado Recio
*
* Copyright (C) 2025 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.owncloud.android.lib.resources.users

import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.http.HttpConstants
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
import com.owncloud.android.lib.resources.spaces.responses.GroupResponse
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonClass
import com.squareup.moshi.Moshi
import timber.log.Timber
import java.net.URL

class GetRemoteUserGroupsOperation: RemoteOperation<List<String>>() {
override fun run(client: OwnCloudClient): RemoteOperationResult<List<String>> {
var result: RemoteOperationResult<List<String>>
try {
val uriBuilder = client.baseUri.buildUpon().apply {
appendEncodedPath(GRAPH_ME_ENDPOINT)
appendQueryParameter(QUERY_PARAMETER_EXPAND, QUERY_PARAMETER_EXPAND_VALUE)
}

val getMethod = GetMethod(URL(uriBuilder.build().toString()))

val status = client.executeHttpMethod(getMethod)

val response = getMethod.getResponseBodyAsString()

if (status == HttpConstants.HTTP_OK) {
Timber.d("Successful response: $response")

val moshi: Moshi = Moshi.Builder().build()
val adapter: JsonAdapter<GraphMeResponse> = moshi.adapter(GraphMeResponse::class.java)

result = RemoteOperationResult(ResultCode.OK)
result.data = getMethod.getResponseBodyAsString().let { adapter.fromJson(it)!!.memberOf.map {group -> group.id } }

Timber.d("Get user groups completed and parsed to ${result.data}")
} else {
result = RemoteOperationResult(getMethod)
Timber.e("Failed response while getting user groups; status code: $status, response: $response")
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Timber.e(e, "Exception while getting oCIS user groups")
}
return result
}

@JsonClass(generateAdapter = true)
data class GraphMeResponse(val memberOf: List<GroupResponse>)

companion object {
private const val GRAPH_ME_ENDPOINT = "graph/v1.0/me"
private const val QUERY_PARAMETER_EXPAND = "\$expand"
private const val QUERY_PARAMETER_EXPAND_VALUE = "memberOf"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ interface UserService : Service {
fun getUserAvatar(avatarDimension: Int): RemoteOperationResult<RemoteAvatarData>
fun getUserId(): RemoteOperationResult<String>
fun getUserPermissions(accountId: String): RemoteOperationResult<List<String>>
fun getUserGroups(): RemoteOperationResult<List<String>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package com.owncloud.android.lib.resources.users.services.implementation
import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.resources.users.GetRemoteUserAvatarOperation
import com.owncloud.android.lib.resources.users.GetRemoteUserGroupsOperation
import com.owncloud.android.lib.resources.users.GetRemoteUserIdOperation
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation
import com.owncloud.android.lib.resources.users.GetRemoteUserPermissionsOperation
Expand All @@ -53,4 +54,7 @@ class OCUserService(override val client: OwnCloudClient) : UserService {
override fun getUserPermissions(accountId: String): RemoteOperationResult<List<String>> =
GetRemoteUserPermissionsOperation(accountId).execute(client)

override fun getUserGroups(): RemoteOperationResult<List<String>> =
GetRemoteUserGroupsOperation().execute(client)

}
Loading
Loading