Skip to content

Commit ce34866

Browse files
authored
Merge branch 'master' into chore/remove-talk
2 parents 13fe75d + 8e51ed7 commit ce34866

File tree

29 files changed

+1502
-36
lines changed

29 files changed

+1502
-36
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ ownCloud admins and users.
5151
* Enhancement - Update test in GitHub Actions: [#4663](https://github.com/owncloud/android/pull/4663)
5252
* Enhancement - New workflow to generate a build from "latest" tag on demand: [#4681](https://github.com/owncloud/android/pull/4681)
5353
* Enhancement - Make Update test more robust: [#4690](https://github.com/owncloud/android/pull/4690)
54+
* Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698)
5455

5556
## Details
5657

@@ -156,6 +157,13 @@ ownCloud admins and users.
156157

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

160+
* Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698)
161+
162+
A new field representing the user role has been added to the space model and to
163+
the spaces table in the database.
164+
165+
https://github.com/owncloud/android/pull/4698
166+
159167
# Changelog for ownCloud Android Client [4.6.2] (2025-08-13)
160168

161169
The following sections list the changes in ownCloud Android Client 4.6.2 relevant to

changelog/unreleased/4698

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Add user role to spaces
2+
3+
A new field representing the user role has been added to the space model and to the spaces table in the database.
4+
5+
https://github.com/owncloud/android/pull/4698

owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/UseCaseModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import com.owncloud.android.domain.transfers.usecases.UpdatePendingUploadsPathUs
109109
import com.owncloud.android.domain.user.usecases.GetStoredQuotaUseCase
110110
import com.owncloud.android.domain.user.usecases.GetStoredQuotaAsStreamUseCase
111111
import com.owncloud.android.domain.user.usecases.GetUserAvatarAsyncUseCase
112+
import com.owncloud.android.domain.user.usecases.GetUserGroupsAsyncUseCase
112113
import com.owncloud.android.domain.user.usecases.GetUserInfoAsyncUseCase
113114
import com.owncloud.android.domain.user.usecases.GetUserQuotasUseCase
114115
import com.owncloud.android.domain.user.usecases.GetUserQuotasAsStreamUseCase
@@ -269,6 +270,7 @@ val useCaseModule = module {
269270
factoryOf(::GetStoredQuotaAsStreamUseCase)
270271
factoryOf(::GetStoredQuotaUseCase)
271272
factoryOf(::GetUserAvatarAsyncUseCase)
273+
factoryOf(::GetUserGroupsAsyncUseCase)
272274
factoryOf(::GetUserIdAsyncUseCase)
273275
factoryOf(::GetUserInfoAsyncUseCase)
274276
factoryOf(::GetUserPermissionsAsyncUseCase)

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/spaces/responses/SpacesResponse.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ data class RootResponse(
6464
val id: String,
6565
val webDavUrl: String,
6666
val deleted: DeleteResponse?,
67+
val permissions: List<PermissionsResponse>?
6768
)
6869

6970
@JsonClass(generateAdapter = true)
@@ -97,3 +98,20 @@ data class DeleteResponse(
9798
data class SpecialFolderResponse(
9899
val name: String
99100
)
101+
102+
@JsonClass(generateAdapter = true)
103+
data class PermissionsResponse(
104+
val grantedToV2: GrantedToV2Response,
105+
val roles: List<String>
106+
)
107+
108+
@JsonClass(generateAdapter = true)
109+
data class GrantedToV2Response(
110+
val user: UserResponse?,
111+
val group: GroupResponse?
112+
)
113+
114+
@JsonClass(generateAdapter = true)
115+
data class GroupResponse(
116+
val id: String
117+
)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author Jorge Aguado Recio
5+
*
6+
* Copyright (C) 2025 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.lib.resources.users
22+
23+
import com.owncloud.android.lib.common.OwnCloudClient
24+
import com.owncloud.android.lib.common.http.HttpConstants
25+
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod
26+
import com.owncloud.android.lib.common.operations.RemoteOperation
27+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
28+
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
29+
import com.owncloud.android.lib.resources.spaces.responses.GroupResponse
30+
import com.squareup.moshi.JsonAdapter
31+
import com.squareup.moshi.JsonClass
32+
import com.squareup.moshi.Moshi
33+
import timber.log.Timber
34+
import java.net.URL
35+
36+
class GetRemoteUserGroupsOperation: RemoteOperation<List<String>>() {
37+
override fun run(client: OwnCloudClient): RemoteOperationResult<List<String>> {
38+
var result: RemoteOperationResult<List<String>>
39+
try {
40+
val uriBuilder = client.baseUri.buildUpon().apply {
41+
appendEncodedPath(GRAPH_ME_ENDPOINT)
42+
appendQueryParameter(QUERY_PARAMETER_EXPAND, QUERY_PARAMETER_EXPAND_VALUE)
43+
}
44+
45+
val getMethod = GetMethod(URL(uriBuilder.build().toString()))
46+
47+
val status = client.executeHttpMethod(getMethod)
48+
49+
val response = getMethod.getResponseBodyAsString()
50+
51+
if (status == HttpConstants.HTTP_OK) {
52+
Timber.d("Successful response: $response")
53+
54+
val moshi: Moshi = Moshi.Builder().build()
55+
val adapter: JsonAdapter<GraphMeResponse> = moshi.adapter(GraphMeResponse::class.java)
56+
57+
result = RemoteOperationResult(ResultCode.OK)
58+
result.data = getMethod.getResponseBodyAsString().let { adapter.fromJson(it)!!.memberOf.map {group -> group.id } }
59+
60+
Timber.d("Get user groups completed and parsed to ${result.data}")
61+
} else {
62+
result = RemoteOperationResult(getMethod)
63+
Timber.e("Failed response while getting user groups; status code: $status, response: $response")
64+
}
65+
} catch (e: Exception) {
66+
result = RemoteOperationResult(e)
67+
Timber.e(e, "Exception while getting oCIS user groups")
68+
}
69+
return result
70+
}
71+
72+
@JsonClass(generateAdapter = true)
73+
data class GraphMeResponse(val memberOf: List<GroupResponse>)
74+
75+
companion object {
76+
private const val GRAPH_ME_ENDPOINT = "graph/v1.0/me"
77+
private const val QUERY_PARAMETER_EXPAND = "\$expand"
78+
private const val QUERY_PARAMETER_EXPAND_VALUE = "memberOf"
79+
}
80+
81+
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/services/UserService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ interface UserService : Service {
3636
fun getUserAvatar(avatarDimension: Int): RemoteOperationResult<RemoteAvatarData>
3737
fun getUserId(): RemoteOperationResult<String>
3838
fun getUserPermissions(accountId: String): RemoteOperationResult<List<String>>
39+
fun getUserGroups(): RemoteOperationResult<List<String>>
3940
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/services/implementation/OCUserService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ package com.owncloud.android.lib.resources.users.services.implementation
2929
import com.owncloud.android.lib.common.OwnCloudClient
3030
import com.owncloud.android.lib.common.operations.RemoteOperationResult
3131
import com.owncloud.android.lib.resources.users.GetRemoteUserAvatarOperation
32+
import com.owncloud.android.lib.resources.users.GetRemoteUserGroupsOperation
3233
import com.owncloud.android.lib.resources.users.GetRemoteUserIdOperation
3334
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation
3435
import com.owncloud.android.lib.resources.users.GetRemoteUserPermissionsOperation
@@ -53,4 +54,7 @@ class OCUserService(override val client: OwnCloudClient) : UserService {
5354
override fun getUserPermissions(accountId: String): RemoteOperationResult<List<String>> =
5455
GetRemoteUserPermissionsOperation(accountId).execute(client)
5556

57+
override fun getUserGroups(): RemoteOperationResult<List<String>> =
58+
GetRemoteUserGroupsOperation().execute(client)
59+
5660
}

0 commit comments

Comments
 (0)