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 4f67f76f95ff326c7810406b8ff375c97ecd5711..23139360b4c22faf5f12a03a61d254ee690fe73b 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 700338d0f9e22b5a69e04faea94f03d2633b04a9..741e8938107a0fc0b0261e8c8d24c05fd6888714 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()) {