Migrate CheckCurrentCredentialsOperation to User

Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
Chris Narkiewicz 2021-01-16 20:04:36 +00:00
parent 2cc7788b7f
commit d06463bbc5
No known key found for this signature in database
GPG key ID: 30D28CA4CCC665C6
2 changed files with 9 additions and 9 deletions

View file

@ -22,6 +22,7 @@ package com.owncloud.android.operations;
import android.accounts.Account;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
@ -36,19 +37,17 @@ import java.util.ArrayList;
*/
public class CheckCurrentCredentialsOperation extends SyncOperation {
private Account mAccount;
private final User user;
public CheckCurrentCredentialsOperation(Account account) {
if (account == null) {
throw new IllegalArgumentException("NULL account");
}
mAccount = account;
public CheckCurrentCredentialsOperation(User user) {
this.user = user;
}
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
if (!getStorageManager().getAccount().name.equals(mAccount.name)) {
boolean validAccount = user.nameEquals(getStorageManager().getAccount().name);
if (!validAccount) {
result = new RemoteOperationResult(new IllegalStateException(
"Account to validate is not the account connected to!")
);
@ -56,9 +55,10 @@ public class CheckCurrentCredentialsOperation extends SyncOperation {
RemoteOperation check = new ExistenceCheckRemoteOperation(OCFile.ROOT_PATH, false);
result = check.execute(client);
ArrayList<Object> data = new ArrayList<>();
data.add(mAccount);
data.add(user.toPlatformAccount());
result.setData(data);
}
return result;
}

View file

@ -672,7 +672,7 @@ public class OperationsService extends Service {
break;
case ACTION_CHECK_CURRENT_CREDENTIALS:
operation = new CheckCurrentCredentialsOperation(account);
operation = new CheckCurrentCredentialsOperation(user);
break;
case ACTION_RESTORE_VERSION: