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

Show sharees via propfind #14429

Merged
merged 11 commits into from
Aug 13, 2019
Merged

Conversation

tobiasKaminsky
Copy link
Member

@tobiasKaminsky tobiasKaminsky commented Feb 28, 2019

❗ TODO: once this is merged, change/check OCFileListAdapter: showShareAvatar boolean ❗

Steps to test

  • create a file "share"
  • share this file to userA and userB
  • do a propfind with nc:sharees/, e.g.:
curl --request PROPFIND \
  --url http://localhost/nc/remote.php/webdav/share \
  --header 'authorization: Basic dG9iaTplOGVrei1SbVpaVC1DMkdDTi01clk2My1BeTl5QQ==' \
  --header 'content-type: application/xml' \
  --header 'ocs-apirequest: true' \
  --cookie 'ocjycgrudn78=vgovrq3bgraie6rs6ai2sl42ag; oc_sessionPassphrase=oyqxSU8b6n4N8Aj0yfObGeheppYvsdzgMhEkMgHw76nWBRLVRRM%252FZcjxqQ5QHtm3knScFxIKIjCzDasJYhLEYxRsvabseMjOqDSa%252BNSkI%252Fi%252FDrm6cKlWmA4QBr3NtcGI; nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true' \
  --data '<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D="DAV:">
<D:prop>
	
<sharees xmlns="http://nextcloud.org/ns" />
</D:prop></D:propfind>
'
  • see:
    • Federated sharee: <nc:sharees>tobi@http://localhost/nc15</nc:sharees>
    • Multiple sharees on same server: <nc:sharees>admin, Tobi Kaminsky</nc:sharees>
    • One sharee on same server: <nc:sharees>admin</nc:sharees>

Please note that this shows only the user you have created & shared a file to.
The other way around (receiving a share) is already exists via < owner-id> and < owner-display-name>.

Signed-off-by: tobiasKaminsky tobias@kaminsky.me

Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

too ambiguous maybe

Share::SHARE_TYPE_ROOM
];

if ($this->getPath() === "/") {
Copy link
Member

Choose a reason for hiding this comment

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

or-connect it with the condition in line 303

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

}
}
}
return implode(', ', $sharees);
Copy link
Member

Choose a reason for hiding this comment

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

ain't it better return the array and format it where the output is being handled (the callee)? This also only works as long as "," is prohibited as identifier. Further, you have all the types mixed in and identifiers are not unique across those types. → What do you want to achieve eventually?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I simply return $sharees, I do get that as plain string, e.g. "adminuser1user2".
If you have a better way, please feel free to change it or give me a hint.
I do not "care" as long as the client has a list of userIds of all sharees.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed Circle and Rooms, so that now only user, remote user and groups are returned.

@blizzz
Copy link
Member

blizzz commented Feb 28, 2019

as discussed on irc, we agreed about not returning grouped by type and and each user, group etc. is inside an id-tag within the appropriate element.

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

So I knew this looked familiar.

Because the way this is implemented it won't scale. If you request this property for a user on a share with 200 entries. It will fire off 300 SQL requests.

We should bundle it with https://github.com/nextcloud/server/blob/master/apps/dav/lib/Connector/Sabre/SharesPlugin.php

$path = $userFolder->get($path);
$this->lock($path);
} catch (\OCP\Files\NotFoundException $e) {
throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
Copy link
Member

Choose a reason for hiding this comment

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

This should not be here

} catch (\OCP\Files\NotFoundException $e) {
throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
} catch (LockedException $e) {
throw new OCSNotFoundException($this->l->t('Could not lock path'));
Copy link
Member

Choose a reason for hiding this comment

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

Same. This is not an OCS endpoint

@tobiasKaminsky
Copy link
Member Author

Bump, can anyone help me here? Or direct me in the right direction? :-)

@MorrisJobke MorrisJobke mentioned this pull request Jul 17, 2019
28 tasks
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@tobiasKaminsky tobiasKaminsky force-pushed the shareesOnDav branch 2 times, most recently from b7c0bdb to b965c79 Compare July 23, 2019 08:33
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@tobiasKaminsky
Copy link
Member Author

tobiasKaminsky commented Jul 23, 2019

I really would like to have this in.

I changed it as good as I can and can help/rewrite if needed.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This makes the XML parsing more sane ;)

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer
Copy link
Member

rullzer commented Jul 31, 2019

Let me fix the tests this evening

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@rullzer
Copy link
Member

rullzer commented Jul 31, 2019

Ok so the test require some more work as they were/are not the cleanest. I'll have a look tomorrow.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer
Copy link
Member

rullzer commented Aug 2, 2019

Test all look good. Time for reviews.

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

All good from my part

@rullzer
Copy link
Member

rullzer commented Aug 2, 2019

Small note. Once we have this we could also enhance the server UI.
We could show who a file is shared to more easily etc.

apps/dav/lib/Connector/Sabre/ShareeList.php Outdated Show resolved Hide resolved
apps/dav/lib/Connector/Sabre/ShareeList.php Outdated Show resolved Hide resolved
@georgehrke
Copy link
Member

Besides those two remarks it looks good and works

no camelCase

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@tobiasKaminsky
Copy link
Member Author

Can you test this please with an admin account:

<nc:sharees>
          <nc:sharee>
            <nc:id>admin</nc:id>
            <nc:display-name/>
            <nc:type>1</nc:type>
          </nc:sharee>
          <nc:sharee>
            <nc:id>user1</nc:id>
            <nc:display-name>User One</nc:display-name>
            <nc:type>0</nc:type>
          </nc:sharee>
          <nc:sharee>
            <nc:id>user2</nc:id>
            <nc:display-name>user2</nc:display-name>
            <nc:type>0</nc:type>
          </nc:sharee>
        </nc:sharees>

For some reason the display name of an admin is missing, but it should be at least userId.
It is working for other users…
I just want to be sure if this is a problem of my local system…

foreach ($this->shares as $share) {
$writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName() ?? $share->getSharedWith());

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote a test for android library and there the problem also exists.
It seems that always one of the display names is set to userId.

@tobiasKaminsky
Copy link
Member Author

BUG:

  • create folder "testFolder"
  • share it to user1, user2
  • query "/remote.php/webdav/", see
 <d:response>
    <d:href>/remote.php/webdav/testFolder/</d:href>
    <d:propstat>
      <d:prop>
        <nc:sharees>
          <nc:sharee>
            <nc:id>user1</nc:id>
            <nc:display-name>User One</nc:display-name>
            <nc:type>0</nc:type>
          </nc:sharee>
          <nc:sharee>
            <nc:id>user2</nc:id>
            <nc:display-name>user2</nc:display-name>
            <nc:type>0</nc:type>
          </nc:sharee>
        </nc:sharees>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  • query "/remote.php/webdav/testFolder", see:
 <d:response>
    <d:href>/remote.php/webdav/testFolder/</d:href>
    <d:propstat>
      <d:prop>
        <nc:sharees>
          <nc:sharee>
            <nc:id>user1</nc:id>
            <nc:display-name>User One</nc:display-name>
            <nc:type>0</nc:type>
          </nc:sharee>
        </nc:sharees>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@tobiasKaminsky
Copy link
Member Author

Bug fixed via latest commit.

@tobiasKaminsky
Copy link
Member Author

From my side this is ready to get in

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer
Copy link
Member

rullzer commented Aug 11, 2019

Fixed the failing tests

Copy link
Member

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

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

Seems to do what its supposed do and webdav compliance wise I'm also happy with it 👍

@rullzer rullzer merged commit 34868f0 into nextcloud:master Aug 13, 2019
@tobiasKaminsky tobiasKaminsky deleted the shareesOnDav branch August 14, 2019 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants