From ab3c41468f2fd6ed8bb707abb95fdbe10f65ae47 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Thu, 30 Jun 2022 12:17:27 +0530 Subject: [PATCH] eDrive: Properly user Id to fetch aliases and also use email for email --- .../foundation/e/drive/operations/GetAliasOperation.java | 7 ++++++- .../foundation/e/drive/work/AccountUserInfoWorker.java | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/operations/GetAliasOperation.java b/app/src/main/java/foundation/e/drive/operations/GetAliasOperation.java index 4f67f76f..23139360 100644 --- a/app/src/main/java/foundation/e/drive/operations/GetAliasOperation.java +++ b/app/src/main/java/foundation/e/drive/operations/GetAliasOperation.java @@ -35,16 +35,21 @@ public class GetAliasOperation extends RemoteOperation { private static final String NODE_DATA = "data"; private static final String NODE_ALIASES = "aliases"; + private final String mID; private boolean isSuccess(int status) { return (status == HttpStatus.SC_OK); } + public GetAliasOperation(String id) { + mID = id; + } + @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; GetMethod get = null; - final String uri = client.getBaseUri() + ALIAS_PATH + client.getCredentials().getUsername(); + final String uri = client.getBaseUri() + ALIAS_PATH + mID; try { get = new GetMethod(uri); diff --git a/app/src/main/java/foundation/e/drive/work/AccountUserInfoWorker.java b/app/src/main/java/foundation/e/drive/work/AccountUserInfoWorker.java index 700338d0..741e8938 100644 --- a/app/src/main/java/foundation/e/drive/work/AccountUserInfoWorker.java +++ b/app/src/main/java/foundation/e/drive/work/AccountUserInfoWorker.java @@ -52,9 +52,9 @@ public class AccountUserInfoWorker extends Worker { public static final String UNIQUE_WORK_NAME = "AccountUserInfoWorker"; final AccountManager accountManager; final GetRemoteUserInfoOperation getRemoteUserInfoOperation = new GetRemoteUserInfoOperation(); - final GetAliasOperation getAliasOperation = new GetAliasOperation(); private final Context mContext; private Account account; + private String id; public AccountUserInfoWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { super(context, workerParams); @@ -91,6 +91,7 @@ public class AccountUserInfoWorker extends Worker { if (ocsResult.isSuccess() && ocsResult.getData() != null && !ocsResult.getData().isEmpty()) { final UserInfo userInfo = (UserInfo) ocsResult.getData().get(0); + id = userInfo.id; final String name; if (userInfo.displayName == null || userInfo.displayName.isEmpty()) { name = userInfo.alternateDisplayName; @@ -104,7 +105,7 @@ public class AccountUserInfoWorker extends Worker { } final long usedQuota = userInfo.getQuota().used; final String groups = String.join(",", userInfo.groups); - final String email = userInfo.id; + final String email = userInfo.email; accountManager.setUserData(account, ACCOUNT_DATA_NAME, name); accountManager.setUserData(account, ACCOUNT_DATA_EMAIL, email); @@ -179,6 +180,7 @@ public class AccountUserInfoWorker extends Worker { } private boolean fetchAliases(final OwnCloudClient client) { + final GetAliasOperation getAliasOperation = new GetAliasOperation(id); final RemoteOperationResult ocsResult = getAliasOperation.execute(client); String aliases = ""; if (ocsResult.isSuccess() && ocsResult.getData() != null && !ocsResult.getData().isEmpty()) { -- GitLab