Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webdav property for share info in PROPFIND response #22789

Merged
merged 4 commits into from
Mar 21, 2016

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Mar 2, 2016

POC for #22708

To test

  1. Put this in "propfind.txt":
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns">
        <a:prop>
        <oc:id/>
        <oc:fileid/>
        <oc:owner-id/>
        <oc:owner-display-name/>
        <oc:shares/>
        </a:prop>
</a:propfind>

Then: curl -D - -X PROPFIND -H "Content-Type: application/xml" --data-binary "@propfind.txt" http://admin:admin@localhost/owncloud/remote.php/files

Make sure to have something shares, then check the "oc:shares" response.

Tasks

  • TODO: decide what info we want to return: for the files app we actually only need a list of share types to be able to show icons, so we might want to rename it to oc:shareTypes or something
  • TODO: optionally we could also return a full list of shares + recipients
  • TODO: check performance
  • TODO: check boundaries, whether $paths are resolved properly, etc
  • TODO: unit tests
  • TODO: make the web UI use it (can be done separately)

@rullzer @DeepDiver1957 @blizzz

*/
private function getShares($node) {
$shares = [];
$shareTypes = [0, 1, 3]; // FIXME: use constants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants are in \OCP\Share:: for now... I still need to think where to move those properly.

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 2, 2016

So far we have to call getShares() 3 times for every file. So for a folder with 100 files it would be called 300 times.

To improve this, we could at some point add a specialized API call for this in the share manager:

    $shareTypes = $this->shareManager->getOutgoingShareTypes($userId, $nodes);

where $nodes is an array of multiple nodes.
This would only produce a single select:

   SELECT DISTINCT shareType FROM *PREFIX*share WHERE item_source IN (...)

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 2, 2016

and of course might need to chunk the IN parameters thanks to SQLite and others...

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 3, 2016

  • TODO: make sure this also works with reshares

@PVince81
Copy link
Contributor Author

Web UI was changed to make use of the new property.
Now the following lists properly display the sharing status:

  • "All files"
  • "Tags"
  • "Shared with others"
  • "Shared with link"

However the "Favorite" list doesn't use webdav yet, so that one is still missing the share status...

Basically the only benefits of this PR are:

  • no more delay in the web UI until the share status appears
  • legacy JS sharing code can be removed (for 9.1), OC.Share.loadIcons, OC.Share.updateIcons, etc
  • the "Tags" list is able to display the share status thanks to the Webdav property

How about I rename "oc:share" to "oc:shareTypes" ? Is it ok to have a comma separated list or do we want more fancy <oc:shareTypes><oc:shareType>1</oc:shareType><oc:shareType>3</oc:shareType></oc:shareTypes> ? Or like the permissions <oc:shareTypes>UGL</oc:shareTypes> ? (User, Group, Link)

@rullzer
Copy link
Contributor

rullzer commented Mar 15, 2016

I prefer the fancy way:

<oc:shareTypes>
  <oc:shareType>1</oc:shareType>
  <oc:shareType>3</oc:shareType>
</oc:shareTypes>

@PVince81
Copy link
Contributor Author

Added 0045d7b to also fix the favorite file list. While it doesn't use the new webdav property, it still needs the JS changes from this PR to work. That's why I put them together inside the same PR.

@PVince81
Copy link
Contributor Author

@rullzer ok, I settled on this format:

<oc:share-types>
    <oc:share-type>1</oc:share-type>
    <oc:share-type>3</oc:share-type>
</oc:share-types>

using dashes instead of camel case because other properies are alike.

I haven't pushed yet, will add some unit tests first.

@PVince81
Copy link
Contributor Author

Ok, I'm done.

To test:

  1. Create a folder "sub"
  2. Create a bunch of subfolders "sub/user", "sub/group", "sub/link", "sub/user_link", "sub/nonshared", etc
  3. Mark all subfolders as favorite
  4. Tag all subfolders with "tag1"
  5. For each subfolder, share it with a "user", "group" or "link" or any combination of those
  6. Go to "sub" inside "All files" => share statuses must be displayed
  7. Go to "Favorites" => share statuses must be displayed
  8. Go to "Tags" and filter by "tag1" => share statuses must be displayed
  9. Go to "Shared with others" => share statuses must be displayed
  10. Go to "Shared with link" => share statuses must be displayed (only link shares)

Before this fix: share statuses were missing in the "Tags" and "Favorite" section
After this fix: share statuses displayed

Note: the other sections in the steps are only for regression testing.

Please review @rullzer @nickvergessen @icewind1991 @MorrisJobke @schiesbn @SergioBertolinSG

@MorrisJobke
Copy link
Contributor

PHP Fatal error:  Uncaught TypeError: Argument 3 passed to OCA\Files\Controller\ApiController::__construct() must implement interface OCP\IUserSession, instance of Mock_TagService_864a049d given, called in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files/tests/controller/apicontrollertest.php on line 70 and defined in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files/controller/apicontroller.php:63
Stack trace:
#0 /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files/tests/controller/apicontrollertest.php(70): OCA\Files\Controller\ApiController->__construct('files', Object(Mock_IRequest_e343c747), Object(Mock_TagService_864a049d), Object(Mock_IPreview_700bdc2c))
#1 phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php(739): OCA\Files\Controller\ApiControllerTest->setUp()
#2 phar:///usr/local/bin/phpunit/php-invoker/Invoker.php(93): PHPUnit_Framework_TestCase->runBare()
#3 phar:///usr/local/bin/phpunit/php in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files/controller/apicontroller.php on line 63

@PVince81
Copy link
Contributor Author

Weeeird, when I tested it locally it worked. Maybe I messed up my rebase.

I'll have a look.

@PVince81
Copy link
Contributor Author

Ah yes of course, the unit test of the controller needs adjusting... forgot that

@PVince81
Copy link
Contributor Author

Fixed ApiController tests

@MorrisJobke
Copy link
Contributor

This happened after switching to master (to compare) and switch back. (I dunno if this was also broken before the switch)

@MorrisJobke
Copy link
Contributor

Beside the above this works :)

@rullzer
Copy link
Contributor

rullzer commented Mar 17, 2016

Ok fixed... we need to deserializer for the repots stuff...

@MorrisJobke please have another look.

@rullzer
Copy link
Contributor

rullzer commented Mar 17, 2016

Seems we should also have intergration tests for the report methods..

@MorrisJobke
Copy link
Contributor

Retested and works now 👍

@PVince81
Copy link
Contributor Author

@karlitschek backport to 9.0.1 ?

@PVince81
Copy link
Contributor Author

stable9: #23384

@karlitschek
Copy link
Contributor

please backport 👍

@DeepDiver1975
Copy link
Member

Where is the necessity of the backport coming from?

@@ -137,6 +137,12 @@ public function createServer($baseUri,

if($this->userSession->isLoggedIn()) {
$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this plugin has to be added to the v2 endpoint as well

@rullzer can I ask you to duplicate all webdav tests so that the new endpoint is tested as well? THX

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes added to my TODO... will do

@PVince81
Copy link
Contributor Author

Where is the necessity of the backport coming from?

This is to fix #22708 which is a regression.

@PVince81
Copy link
Contributor Author

@DeepDiver1975 you already merged the backport. Can you also merge this one ?

Then we'll need to make another PR + backport to fix your comments.

DeepDiver1975 added a commit that referenced this pull request Mar 21, 2016
Add webdav property for share info in PROPFIND response
@DeepDiver1975 DeepDiver1975 merged commit 8852fda into master Mar 21, 2016
@DeepDiver1975 DeepDiver1975 deleted the dav-sharesproperty branch March 21, 2016 10:15
@lock
Copy link

lock bot commented Aug 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants