Skip to content

Commit

Permalink
Merge pull request #1385 from nextcloud/feature/add-assistant-capability
Browse files Browse the repository at this point in the history
Add Assistant Capability
  • Loading branch information
alperozturk96 authored Mar 5, 2024
2 parents 6dcffdb + 554d4a8 commit fcb36db
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
38 changes: 19 additions & 19 deletions library/src/androidTest/java/com/owncloud/android/AbstractIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public abstract class AbstractIT {

@BeforeClass
public static void beforeAll() throws InterruptedException,
CertificateException,
NoSuchAlgorithmException,
KeyStoreException,
IOException {
CertificateException,
NoSuchAlgorithmException,
KeyStoreException,
IOException {
Bundle arguments = InstrumentationRegistry.getArguments();
context = InstrumentationRegistry.getInstrumentation().getTargetContext();

Expand Down Expand Up @@ -138,10 +138,10 @@ private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
}

private static void testConnection() throws KeyStoreException,
CertificateException,
NoSuchAlgorithmException,
IOException,
InterruptedException {
CertificateException,
NoSuchAlgorithmException,
IOException,
InterruptedException {
GetStatusRemoteOperation getStatus = new GetStatusRemoteOperation(context);

RemoteOperationResult result = getStatus.execute(client);
Expand All @@ -159,8 +159,8 @@ private static void testConnection() throws KeyStoreException,
Thread.sleep(1000);

assertEquals(certificate,
NetworkUtils.getKnownServersStore(context)
.getCertificate(Integer.toString(certificate.hashCode()))
NetworkUtils.getKnownServersStore(context)
.getCertificate(Integer.toString(certificate.hashCode()))
);

// retry
Expand Down Expand Up @@ -271,18 +271,18 @@ private void removeOnClient(OwnCloudClient client) {
RemoteFile remoteFile = (RemoteFile) object;

if (!"/".equals(remoteFile.getRemotePath()) &&
remoteFile.getMountType() != WebdavEntry.MountType.GROUP) {
remoteFile.getMountType() != WebdavEntry.MountType.GROUP) {
if (remoteFile.isEncrypted()) {
assertTrue(new ToggleEncryptionRemoteOperation(
remoteFile.getLocalId(),
remoteFile.getRemotePath(),
false)
.execute(client)
.isSuccess());
remoteFile.getLocalId(),
remoteFile.getRemotePath(),
false)
.execute(client)
.isSuccess());
}

assertTrue("Failed to remove " + remoteFile.getRemotePath(),
new RemoveFileRemoteOperation(remoteFile.getRemotePath()).execute(client).isSuccess());
new RemoveFileRemoteOperation(remoteFile.getRemotePath()).execute(client).isSuccess());
}
}

Expand Down Expand Up @@ -316,8 +316,8 @@ protected void longSleep() {

protected void testOnlyOnServer(OwnCloudVersion version) {
OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
.execute(nextcloudClient)
.getSingleData();
.execute(nextcloudClient)
.getSingleData();
assumeTrue(ocCapability.getVersion().isNewerOrEqual(version));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ private void checkCapability(OCCapability capability, String userId) {
assertTrue(capability.getGroupfolders().isFalse());
}

// assistant
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_28)) {
if (userId.equals("test")) {
assertTrue(capability.getAssistant().isTrue());
} else {
assertFalse(capability.getAssistant().isFalse());
}
}

// e2e
assertNotSame(capability.getEndToEndEncryptionApiVersion(), E2EVersion.UNKNOWN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class GetCapabilitiesRemoteOperation extends RemoteOperation {
private static final String PROPERTY_ENABLED = "enabled";
private static final String PROPERTY_ENFORCED = "enforced";
private static final String PROPERTY_DAYS = "days";
private static final String PROPERTY_ASSISTANT = "assistant";
private static final String PROPERTY_SEND_MAIL = "send_mail";
private static final String PROPERTY_UPLOAD = "upload";
private static final String PROPERTY_RESHARING = "resharing";
Expand Down Expand Up @@ -669,6 +670,19 @@ private OCCapability parseResponse(String response) throws JSONException {
capability.setGroupfolders(CapabilityBooleanType.FALSE);
}

// assistant
if (respCapabilities.has(PROPERTY_ASSISTANT)) {
JSONObject assistantCapability = respCapabilities.getJSONObject(PROPERTY_ASSISTANT);

if (assistantCapability.getBoolean(PROPERTY_ENABLED)) {
capability.setAssistant(CapabilityBooleanType.TRUE);
} else {
capability.setAssistant(CapabilityBooleanType.FALSE);
}
} else {
capability.setAssistant(CapabilityBooleanType.FALSE);
}

// drop-account
if (respCapabilities.has(NODE_DROP_ACCOUNT)) {
JSONObject dropAccountCapability = respCapabilities.getJSONObject(NODE_DROP_ACCOUNT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class OCCapability {
// Groupfolders
var groupfolders = CapabilityBooleanType.UNKNOWN

var assistant = CapabilityBooleanType.UNKNOWN

// Drop-Account
var dropAccount = CapabilityBooleanType.UNKNOWN

Expand Down

0 comments on commit fcb36db

Please sign in to comment.