-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[FEATURE REQUEST] Add account information to the user #4647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
001aa18
feat: save account id in Accounts Manager for Infinite Scale users
joragua bed2f23
test: adapt AuthenticationViewModelTest and OCUserRepositoryTest for …
joragua 577ac5c
test: create new tests for OCUserRepositoryTest and OCRemoteUserDataS…
joragua d3e9522
style: improve wording for logs in GetRemoteUserIdOperation
joragua 3ac5ccc
chore: add calens file
joragua 4bff01b
docs: calens changelog updated
ownclouders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Enhancement: Add account ID to the user information | ||
|
|
||
| The account ID has been added to the Account Manager only for Infinite Scale users. | ||
| This information will be used to fetch all permissions related to space management. | ||
|
|
||
| https://github.com/owncloud/android/issues/4605 | ||
| https://github.com/owncloud/android/pull/4647 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserIdOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /** | ||
| * 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.squareup.moshi.JsonAdapter | ||
| import com.squareup.moshi.JsonClass | ||
| import com.squareup.moshi.Moshi | ||
| import timber.log.Timber | ||
| import java.net.URL | ||
|
|
||
| class GetRemoteUserIdOperation: RemoteOperation<String>() { | ||
| override fun run(client: OwnCloudClient): RemoteOperationResult<String> { | ||
| var result: RemoteOperationResult<String> | ||
| try { | ||
| val getMethod = GetMethod(URL(client.baseUri.toString() + GRAPH_ME_ENDPOINT)) | ||
|
|
||
| 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)!!.id } | ||
|
|
||
| Timber.d("Get user id completed and parsed to ${result.data}") | ||
| } else { | ||
| result = RemoteOperationResult(getMethod) | ||
| Timber.e("Failed response while getting user id; status code: $status, response: $response") | ||
| } | ||
| } catch (e: Exception) { | ||
| result = RemoteOperationResult(e) | ||
| Timber.e(e, "Exception while getting oCIS user id") | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| @JsonClass(generateAdapter = true) | ||
| data class GraphMeResponse(val id: String) | ||
|
|
||
| companion object { | ||
| private const val GRAPH_ME_ENDPOINT = "/graph/v1.0/me" | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
getMethodas parameter here? shouldn't be any error information likeResultCode.xxx?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor used here takes a
HttpMethodas its parameter. It is intended for cases when the result needs to be interpreted from the response (You can see the implementation in theRemoteOperationResultclass)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 .
RemoteOperationResulthas a bunch of creators calling themselves... that confused me. That's OK