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

returns reshares in API #14605

Merged
merged 5 commits into from
Apr 2, 2019
Merged

returns reshares in API #14605

merged 5 commits into from
Apr 2, 2019

Conversation

ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Mar 9, 2019

(#14112) Returns reshares to the API

@ArtificialOwl ArtificialOwl added bug 3. to review Waiting for reviews labels Mar 9, 2019
@ArtificialOwl ArtificialOwl added this to the Nextcloud 16 milestone Mar 9, 2019
Copy link
Member

@tobiasKaminsky tobiasKaminsky left a comment

Choose a reason for hiding this comment

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

Works for me 👍

@MorrisJobke MorrisJobke mentioned this pull request Mar 20, 2019
9 tasks
@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Mar 20, 2019
@MorrisJobke
Copy link
Member

@daita This breaks the sharing tests.

@tobiasKaminsky
Copy link
Member

@daita for me it seems as if "path" is wrong:

  • have a file /foo with
    • shared with you by user0
    • shared to user1
    • shared to user3
  • be in "/"
  • query /nc/ocs/v2.php/apps/files_sharing/api/v1/shares?path=%2F&reshares=true&subfiles=true
  • get
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>200</statuscode>
  <message>OK</message>
 </meta>
 <data>
  <element>
   <id>401</id>
   <share_type>0</share_type>
   <uid_owner>user0</uid_owner>
   <displayname_owner>user0</displayname_owner>
   <permissions>15</permissions>
   <stime>1549621868</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>user0</uid_file_owner>
   <note></note>
   <label/>
   <displayname_file_owner>user0</displayname_file_owner>
   <path>/</path>
   <item_type>folder</item_type>
   <mimetype>httpd/unix-directory</mimetype>
   <storage_id>home::user2</storage_id>
   <storage>28</storage>
   <item_source>75844</item_source>
   <file_source>75844</file_source>
   <file_parent>75843</file_parent>
   <file_target>/foo</file_target>
   <share_with>user1</share_with>
   <share_with_displayname>user1</share_with_displayname>
   <mail_send>0</mail_send>
   <hide_download>0</hide_download>
  </element>
  <element>
   <id>402</id>
   <share_type>0</share_type>
   <uid_owner>user0</uid_owner>
   <displayname_owner>user0</displayname_owner>
   <permissions>31</permissions>
   <stime>1549621887</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>user0</uid_file_owner>
   <note></note>
   <label/>
   <displayname_file_owner>user0</displayname_file_owner>
   <path>/</path>
   <item_type>folder</item_type>
   <mimetype>httpd/unix-directory</mimetype>
   <storage_id>home::user2</storage_id>
   <storage>28</storage>
   <item_source>75844</item_source>
   <file_source>75844</file_source>
   <file_parent>75843</file_parent>
   <file_target>/foo</file_target>
   <share_with>user2</share_with>
   <share_with_displayname>user2</share_with_displayname>
   <mail_send>0</mail_send>
   <hide_download>0</hide_download>
  </element>
  <element>
   <id>403</id>
   <share_type>0</share_type>
   <uid_owner>user0</uid_owner>
   <displayname_owner>user0</displayname_owner>
   <permissions>31</permissions>
   <stime>1549622481</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>user0</uid_file_owner>
   <note></note>
   <label/>
   <displayname_file_owner>user0</displayname_file_owner>
   <path>/</path>
   <item_type>folder</item_type>
   <mimetype>httpd/unix-directory</mimetype>
   <storage_id>home::user2</storage_id>
   <storage>28</storage>
   <item_source>75844</item_source>
   <file_source>75844</file_source>
   <file_parent>75843</file_parent>
   <file_target>/foo</file_target>
   <share_with>user3</share_with>
   <share_with_displayname>user3</share_with_displayname>
   <mail_send>0</mail_send>
   <hide_download>0</hide_download>
  </element>
 </data>
</ocs>

With master (on a file I shared with user admin):

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>200</statuscode>
  <message>OK</message>
 </meta>
 <data>
  <element>
   <id>423</id>
   <share_type>0</share_type>
   <uid_owner>user2</uid_owner>
   <displayname_owner>user2</displayname_owner>
   <permissions>31</permissions>
   <stime>1553085500</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>user2</uid_file_owner>
   <note></note>
   <label/>
   <displayname_file_owner>user2</displayname_file_owner>
   <path>/share</path>
   <item_type>folder</item_type>
   <mimetype>httpd/unix-directory</mimetype>
   <storage_id>home::user2</storage_id>
   <storage>28</storage>
   <item_source>77824</item_source>
   <file_source>77824</file_source>
   <file_parent>75844</file_parent>
   <file_target>/share</file_target>
   <share_with>admin</share_with>
   <share_with_displayname>admin</share_with_displayname>
   <mail_send>0</mail_send>
   <hide_download>0</hide_download>
  </element>
 </data>
</ocs>

@tobiasKaminsky
Copy link
Member

Another question: should this really return the same user?
I can filter this on client side, but is not useful at all, or?

@ArtificialOwl
Copy link
Member Author

@MorrisJobke @ChristophWurst any reason that most of the errors are from the TwoFactorBackupCodes app ?

@MorrisJobke
Copy link
Member

@MorrisJobke @ChristophWurst any reason that most of the errors are from the TwoFactorBackupCodes app ?

Ignore the risky tests, those are just warnings that there was no check (due to the environment) - the problem here are the failures.

@ArtificialOwl
Copy link
Member Author

@MorrisJobke How can I just run one scenario from the tests ?

@MorrisJobke
Copy link
Member

@MorrisJobke How can I just run one scenario from the tests ?

That should do the trick:

cd tests acceptance
./run.sh features/app-files-sharing-link.feature

@rullzer rullzer mentioned this pull request Mar 26, 2019
9 tasks
@ArtificialOwl ArtificialOwl force-pushed the bugfix/14112/display-reshares branch from a8c14c3 to 2923887 Compare March 30, 2019 21:51
@ArtificialOwl
Copy link
Member Author

@MorrisJobke could not point the source of the issue but my guess is that a rebase (done) should do the trick

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl force-pushed the bugfix/14112/display-reshares branch from d9df077 to 0166990 Compare March 31, 2019 11:40
@ArtificialOwl
Copy link
Member Author

@faily-bot still returns error, but nothing on my own tests, rebasing.

maxence@stealth:~/PhpstormProjects/server$ ./autotest.sh sqlite apps/files_sharing/tests/ApiTest.php 
Using PHP executable /usr/bin/php
Parsing all files in lib/public for the presence of @since or @deprecated on each method...

Using database oc_autotest
Setup environment for sqlite testing on local storage ...
Installing ....
Nextcloud was successfully installed
Testing with sqlite ...
/usr/bin/phpunit --configuration phpunit-autotest.xml --coverage-clover autotest-clover-sqlite.xml --coverage-html coverage-html-sqlite --log-junit autotest-results-sqlite.xml ../apps/files_sharing/tests/ApiTest.php 
PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.2.15-0ubuntu0.18.04.2 with Xdebug 2.6.0
Configuration: /home/maxence/PhpstormProjects/server/tests/phpunit-autotest.xml

...................................                               35 / 35 (100%)

Time: 29.39 seconds, Memory: 56.00MB

OK (35 tests, 76 assertions)

@ArtificialOwl
Copy link
Member Author

ArtificialOwl commented Mar 31, 2019

@MorrisJobke : looks green to me, some hiccup on drone

@tobiasKaminsky
Copy link
Member

@daita have you fixed
#14605 (comment) and #14605 (comment)?

@ArtificialOwl
Copy link
Member Author

The first one is fixed and was the reason of the tests issue.
I don't understand the second one

@@ -609,7 +609,7 @@ public function getSharesInFolder($userId, Folder $node, $reshares) {
*/
public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
$qb->selectDistinct('*')
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

note that I could swap back to select() as I filters duplicate results

Copy link
Member

Choose a reason for hiding this comment

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

So this can go then? Or should we leave it ?

@tobiasKaminsky
Copy link
Member

The first one is fixed and was the reason of the tests issue.

👍 working

I don't understand the second one

 {
        "id": "364",
        "share_type": 0,
        "uid_owner": "admin",
        "displayname_owner": "admin",
        "permissions": 31,
        "stime": 1540475407,
        "parent": null,
        "expiration": null,
        "token": null,
        "uid_file_owner": "admin",
        "note": "",
        "label": null,
        "displayname_file_owner": "admin",
        "path": "\/__sharedByAdmin",
        "item_type": "folder",
        "mimetype": "httpd\/unix-directory",
        "storage_id": "shared::\/__sharedByAdmin",
        "storage": 1,
        "item_source": 72003,
        "file_source": 72003,
        "file_parent": 103,
        "file_target": "\/__sharedByAdmin",
        "share_with": "tobi",
        "share_with_displayname": "Kaminsky Tobi",
        "mail_send": 0,
        "hide_download": 0
      },

This means I cannot simply display all received shares for a given folder, but first have to check if "share_with" is not the username.
As this behaviour changed, I expect that other apps on mobile/web/dav will also need to be changed…

@ArtificialOwl
Copy link
Member Author

@tobiasKaminsky I think it is the main idea behind the edit: displaying all shares if you have reshares rights ? or am I missing something ?

@tobiasKaminsky
Copy link
Member

@tobiasKaminsky I think it is the main idea behind the edit: displaying all shares if you have reshares rights ? or am I missing something ?

But seeing myself as a share is kind of useless, or?

This is how it currently looks like:
File is shared by admin with me (Kaminsky Tobi) and I additionally see myself as a sharee.
2019-04-01-135200

In my expectation it should be this way:

  • with reshare permission see all sharees except your own
    • see what other users admin shared to
    • see your sharees

So, if admin shared this files also to userA, userB and I shared it to friendA, friendB, I would expect that I get this returend via API:

  • userA (read only as I am not allowed to edit this)
  • userB (read only as I am not allowed to edit this)
  • friendA (I can change this)
  • friendB (I can change this)

but I do not see myself in this list

@ArtificialOwl
Copy link
Member Author

Ok, wasn't clear who was the viewer, let me check what can be done

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl
Copy link
Member Author

@tobiasKaminsky can you try now ?

(Also, in my opinion, it should not be filtered by the API but by the client itself)

@tobiasKaminsky
Copy link
Member

@tobiasKaminsky can you try now ?

(Also, in my opinion, it should not be filtered by the API but by the client itself)

works for me now as expected 🎉

@MorrisJobke
Copy link
Member

@rullzer Mind to review?

@nextcloud nextcloud deleted a comment from faily-bot bot Apr 2, 2019
@MorrisJobke MorrisJobke added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 2, 2019
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
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.

Let do this then. 🐘 saw @tobiasKaminsky test it and code makes sese

@rullzer rullzer merged commit b365840 into master Apr 2, 2019
@rullzer rullzer deleted the bugfix/14112/display-reshares branch April 2, 2019 20:59
@MorrisJobke MorrisJobke mentioned this pull request Apr 3, 2019
2 tasks
nickvergessen added a commit to nextcloud/spreed that referenced this pull request Apr 9, 2019
See nextcloud/server#14605 for more information

Signed-off-by: Joas Schilling <coding@schilljs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants