Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit c716b11d authored by Tobias Kaminsky's avatar Tobias Kaminsky Committed by GitHub
Browse files

Merge pull request #2803 from leper/fix_sync_sharing_disabled

Fix syncing if sharing is disabled server side. Fixes #2733.
parents 91b136d2 368275f5
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -71,15 +71,18 @@ public class CapabilitiesDeserializer implements JsonDeserializer<Capabilities>
                response.setFederationShare(outgoing.getAsBoolean());

                final var publicObject = filesSharing.getAsJsonObject("public");
                if (publicObject.has("password")) {
                    final var password = publicObject.getAsJsonObject("password");
                    final var enforced = password.getAsJsonPrimitive("enforced");
                    final var askForOptionalPassword = password.getAsJsonPrimitive("askForOptionalPassword");
                final var isReSharingAllowed = filesSharing.getAsJsonPrimitive("resharing");
                final var defaultPermission = filesSharing.getAsJsonPrimitive("default_permissions");

                response.setDefaultPermission(defaultPermission.getAsInt());
                    response.setPublicPasswordEnforced(enforced.getAsBoolean());
                    response.setAskForOptionalPassword(askForOptionalPassword.getAsBoolean());
                }

                final var isReSharingAllowed = filesSharing.getAsJsonPrimitive("resharing");
                final var defaultPermission = filesSharing.getAsJsonPrimitive("default_permissions");
                response.setDefaultPermission(defaultPermission.getAsInt());
                response.setReSharingAllowed(isReSharingAllowed.getAsBoolean());
            }

+75 −0
Original line number Diff line number Diff line
@@ -366,4 +366,79 @@ public class CapabilitiesDeserializerTest {
        assertFalse("Wrongly reporting that direct editing is supported", capabilities1.isDirectEditingAvailable());

    }


    @Test
    public void testSharingDisabled() {
        //language=json
        final String response = "" +
                "{" +
                "    \"version\": {" +
                "        \"major\": 20," +
                "        \"minor\": 0," +
                "        \"micro\": 7," +
                "        \"string\": \"20.0.7\"," +
                "        \"edition\": \"\"," +
                "        \"extendedSupport\": false" +
                "    }," +
                "    \"capabilities\": {" +
                "        \"core\": {" +
                "            \"pollinterval\": 60," +
                "            \"webdav-root\": \"remote.php/webdav\"" +
                "        }," +
                "        \"notes\": {" +
                "            \"api_version\": [" +
                "                \"0.2\"," +
                "                \"1.1\"" +
                "            ]," +
                "            \"version\": \"4.0.4\"" +
                "        }," +
                "        \"files_sharing\": {" +
                "            \"api_enabled\": true," +
                "            \"public\": {" +
                "                \"enabled\": false," +
                "                \"expire_date\": {" +
                "                    \"enabled\": false" +
                "                }," +
                "                \"multiple_links\": true," +
                "                \"expire_date_internal\": {" +
                "                    \"enabled\": false" +
                "                }," +
                "                \"send_mail\": false," +
                "                \"upload\": true," +
                "                \"upload_files_drop\": true" +
                "            }," +
                "            \"resharing\": false," +
                "            \"user\": {" +
                "                \"send_mail\": false," +
                "                \"expire_date\": {" +
                "                    \"enabled\": true" +
                "                }" +
                "            }," +
                "            \"group_sharing\": false," +
                "            \"group\": {" +
                "                \"enabled\": true," +
                "                \"expire_date\": {" +
                "                    \"enabled\": true" +
                "                }" +
                "            }," +
                "            \"default_permissions\": 31," +
                "            \"federation\": {" +
                "                \"outgoing\": true," +
                "                \"incoming\": true," +
                "                \"expire_date\": {" +
                "                    \"enabled\": true" +
                "                }" +
                "            }," +
                "            \"sharee\": {" +
                "                \"query_lookup_default\": false" +
                "            }" +
                "        }" +
                "    }" +
                "}";
        final var capabilities = deserializer.deserialize(JsonParser.parseString(response), null, null);
        assertNull(capabilities.getETag());
        assertEquals("[\"0.2\",\"1.1\"]", capabilities.getApiVersion());
        assertFalse("Wrongly reporting that direct editing is supported", capabilities.isDirectEditingAvailable());
    }
}