Skip to content

Add OCS API for sharees list - #18234

Merged
schiessle merged 24 commits into
masterfrom
ocs_api_for_sharees_list
Sep 1, 2015
Merged

schiessle merged 24 commits into
masterfrom
ocs_api_for_sharees_list

Conversation

@nickvergessen

Copy link
Copy Markdown
Contributor

@DeepDiver1975 @rullzer

Fix #18117

Todo

  • Add a filter that prevents sharing with the same user/group/remote again
  • Add tests for all methods
  • Make shareType an array
  • Turn existingShares into an array of share IDs instead of strings

Related/Depending

@nickvergessen

Copy link
Copy Markdown
Contributor Author

code_coverage_for_home_nickv_owncloud_master_core_apps_files_sharing_api_sharees php_-_2015-08-12_15 09 23

@DeepDiver1975

Copy link
Copy Markdown
Contributor

As per specification multiple shareTypes can be passed in

$ curl -g -v -u admin "http://localhost:8080/ocs/v1.php/apps/files_sharing/api/v1/sharees?itemType=file&shareType[]=0&shareType[]=1"

Comment thread apps/files_sharing/api/sharees.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do the array_map first and then the array_filter. Just 1 array_filter with callback should do the trick

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, I just forgot

Comment thread apps/files_sharing/api/sharees.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread apps/files_sharing/api/sharees.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just saying, this is a performance hell, we grab all users and trim the sorted result later.
The problem is our custom sorter does not work on the user/group backend as they can only sort by uid/gid

If user enumeration is disabled, we can change this to a simple check if the group/user exists, but if type hinting is enabled it's 😞

The custom sorter moves results to the beginning of the list, which start with the entered search term. If searchDisplayName() would support wildcards, we could easily circumvent this, by running two requests:

  1. search* and 2. *search* - both with a limit

But for now this seems to be implossible @DeepDiver1975

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I share your concern. This approach can really hurt on huge installations.
But if we want to present merged results like this I do not really see an other option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well the old version (ajax.php) did not grab all users. The only disadvantage was, that the sorting was different (uid, gid, instead of starting with searchterm, otherwise sort by label).
I guess there are people which prefer the "nicer" way of sorting.

But I'd say it's not worth the performance troubles. This will make the drop down unusable on installations with a few hundred users/groups.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perf hell: no thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But lets move this in to allow Clients to implement this feature.
We can work in perf afterwards.

@nickvergessen
nickvergessen force-pushed the ocs_api_for_sharees_list branch from 9f85d1e to 91071f1 Compare August 17, 2015 14:14
@ghost

ghost commented Aug 17, 2015

Copy link
Copy Markdown

💣 Test FAILed. 💣
nooo432

@DeepDiver1975

Copy link
Copy Markdown
Contributor

PostgreSQL

OCA\Files_Sharing\Tests\API\ShareesTest::testGetShareesForShareIds with data set #1 (array(1, 2, 3), array(array('user1'), array('group1')))
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'INSERT INTO "oc_share" ("share_type", "share_with", "uid_owner", "parent", "item_type", "item_source", "item_target", "file_source", "file_target", "permissions", "stime", "accepted", "expiration", "token", "mail_send") VALUES(?, ?, ?, ?, 'fake', '', '', '0', '', '0', '0', '0', '', '', '0')' with params [0, "user1", "test7v2g8jX2wj0x5", null]:

SQLSTATE[22007]: Invalid datetime format: 7 ERROR:  invalid input syntax for type timestamp: ""
LINE 1: ..., $3, $4, 'fake', '', '', '0', '', '0', '0', '0', '', '', '0...
                                                             ^

/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:91
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:996
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/lib/private/db/connection.php:203
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php:208
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/lib/private/db/querybuilder/querybuilder.php:121
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/apps/files_sharing/tests/api/shareestest.php:860
/var/jenkins/workspace/pull-request-analyser-ng-simple@2/label/SLAVE/apps/files_sharing/tests/api/shareestest.php:804

@nickvergessen
nickvergessen force-pushed the ocs_api_for_sharees_list branch from 91071f1 to 3951415 Compare August 19, 2015 08:14
@nickvergessen

Copy link
Copy Markdown
Contributor Author

hmpf, forgot to push...

Anyway, rebased and pushed now

@ghost

ghost commented Aug 19, 2015

Copy link
Copy Markdown

💣 Test FAILed. 💣
nooo432

@ghost

ghost commented Aug 19, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

To ensure that pagination is working properly we need to make sure the
shares are always in the same order.

Sorting is first done by label (catches most instances)
If there is a user and a group with the same label we sort by shareType
If there are multiple users with the same label we sort those by
shareWith
@nickvergessen
nickvergessen force-pushed the ocs_api_for_sharees_list branch from 0cd07d4 to 199d1dc Compare August 26, 2015 09:54
@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@nickvergessen

Copy link
Copy Markdown
Contributor Author

Fixed all the points that would result in performance issues or incorrect results

@ghost

ghost commented Aug 26, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

@rullzer

rullzer commented Aug 29, 2015

Copy link
Copy Markdown
Contributor

Why the exact part in the response? Clients know what they requested right. So they can pretty easily find the exact match on their own...

@nickvergessen

Copy link
Copy Markdown
Contributor Author

exact parts are full matches === term instead of wildcard matches LIKE %term%
Those should be listed first

@rullzer

rullzer commented Aug 29, 2015

Copy link
Copy Markdown
Contributor

looking good 👍

@schiessle

Copy link
Copy Markdown
Contributor

code looks good 👍

schiessle added a commit that referenced this pull request Sep 1, 2015
@schiessle
schiessle merged commit 39bd4ea into master Sep 1, 2015
@schiessle
schiessle deleted the ocs_api_for_sharees_list branch September 1, 2015 15:09
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 10, 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.

[OCS-API] get sharing recipients

5 participants