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 OCS API for sharees list #18234

Merged
merged 24 commits into from
Sep 1, 2015
Merged

Add OCS API for sharees list #18234

merged 24 commits into from
Sep 1, 2015

Conversation

nickvergessen
Copy link
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
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
Member

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"

return in_array($sharee['value']['shareWith'], $existingSharees) ? null : $sharee;
}, $potentialSharees);

return array_filter($sharees);
Copy link
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
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

* @return bool True if the entry is an autocomplete hint, false otherwise
*/
protected function filterAutocompletion($search, $sharee, $label) {
if ($this->config->getSystemValue('webui-sharing-autocompletion.enabled', true)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$users = array_unique($users);
} else {
// Search in all users
$users_tmp = $this->userManager->searchDisplayName($search);
Copy link
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
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
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
Member

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
Member

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.

@ghost
Copy link

ghost commented Aug 17, 2015

💣 Test FAILed. 💣
nooo432

@DeepDiver1975
Copy link
Member

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
Copy link
Contributor Author

hmpf, forgot to push...

Anyway, rebased and pushed now

@ghost
Copy link

ghost commented Aug 19, 2015

💣 Test FAILed. 💣
nooo432

@ghost
Copy link

ghost commented Aug 19, 2015

🚀 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
@scrutinizer-notifier
Copy link

A new inspection was created.

@nickvergessen
Copy link
Contributor Author

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

@ghost
Copy link

ghost commented Aug 26, 2015

🚀 Test PASSed.🚀
chuck

@rullzer
Copy link
Contributor

rullzer commented Aug 29, 2015

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
Contributor Author

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

@rullzer
Copy link
Contributor

rullzer commented Aug 29, 2015

looking good 👍

@schiessle
Copy link
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