Skip to content

Better result handling of email search - #8206

Merged
blizzz merged 1 commit into
masterfrom
bugfix/noid/fix-collaboration-result-size
Feb 20, 2018
Merged

Better result handling of email search#8206
blizzz merged 1 commit into
masterfrom
bugfix/noid/fix-collaboration-result-size

Conversation

@nickvergessen

@nickvergessennickvergessen commented Feb 6, 2018

Copy link
Copy Markdown
Member
  1. Local users should not be returned when searching for empty string
  2. The limit of the response should be respected

Master version of #8205

if (!$this->shareeEnumeration) {
$result['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🙈

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@nickvergessen Can we somehow limit that result at the query already? Otherwise it will still return a list of all users with mail addresses.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Can we somehow limit that result at the query already?

No, because they could have multiple emails (too many results) or could be internal and unreachable (too few results).

Otherwise it will still return a list of all users with mail addresses.

The query yes, but the API returns as per limit and offset with this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, just found that it is an LDAP only issue, where the size is not limited. I'll create a new issue for that.

$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN']);
$lowerSearch = strtolower($search);
foreach ($addressBookContacts as $contact) {
if ($search === '' && isset($contact['isLocalSystemBook'])) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mmmm that feels weird. Shouldn't the endpoint merge identical results. Because with such a plugin system I would not expect such logic....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Basically what I'm afraid of is that at some somebody wants to search only by email. And then this might do 💥

I mean worst case is that you get another 'maxResults' returned right?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This is only with empty search string. You already get max results of users from getUsers().
Also I would not know how it is possible, to specify which result types you want to receive, so you could only query for emails.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

But yeah well we can also remove this and only keep the array_slice. That would improve the problem for the talk app already a lot.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Removed it for now. Lets do this :)

@rullzer
rullzerforce-pushed the bugfix/noid/fix-collaboration-result-size branch from e1a5bf4 to fbb6988CompareFebruary 8, 2018 20:16
@codecov

codecovBot commented Feb 8, 2018

Copy link
Copy Markdown

Codecov Report

Merging #8206 into master will decrease coverage by <.01%.
The diff coverage is 75%.

@@ Coverage Diff @@## master #8206 +/- ##
============================================
- Coverage 51.75% 51.75% -0.01% 
Complexity 25363 25363 ============================================
Files 1601 1601 Lines 95014 95018 +4 Branches 1377 1377 ============================================
+ Hits 49178 49179 +1 - Misses 45836 45839 +3
Impacted FilesCoverage ΔComplexity Δ
...private/Collaboration/Collaborators/MailPlugin.php73.19% <100%> (-0.49%)27 <0> (ø)
...ivate/Collaboration/Collaborators/RemotePlugin.php72.58% <50%> (-0.76%)17 <0> (ø)
apps/files_trashbin/lib/Trashbin.php72.46% <0%> (-0.25%)136% <0%> (ø)

@nickvergessen

Copy link
Copy Markdown
MemberAuthor

@schiessle can you review this please?

@MorrisJobke

Copy link
Copy Markdown
Member

CI fails:

Test\Collaboration\Collaborators\MailPluginTest::testSearch with data set #5 ('test', array(array('User3 @ Localhost'), array('User2 @ Localhost', array()), array('User @ Localhost', array('username@localhost'))), true, array(array(array('User @ Localhost (username@localhost)', array(4, 'username@localhost'))), array(array())), false, true)

@nickvergessen
nickvergessenforce-pushed the bugfix/noid/fix-collaboration-result-size branch from fbb6988 to f36663eCompareFebruary 20, 2018 13:48
@nickvergessen

Copy link
Copy Markdown
MemberAuthor

Fixed the tests

@MorrisJobke

MorrisJobke commented Feb 20, 2018

Copy link
Copy Markdown
Member

Fixed the tests

Not really :(

1) Test\Collaboration\Collaborators\RemotePluginTest::testSearch with data set #4 ('test', array(array('User3 @ Localhost'), array('User2 @ Localhost', array()), array('User @ Localhost', array('username@localhost'))), true, array(array(array('User @ Localhost (username@localhost)', array(6, 'username@localhost', 'localhost'))), array(array())), false, true)
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
'remotes' => Array (
- 0 => Array (...)
/drone/src/github.com/nextcloud/server/tests/lib/Collaboration/Collaborators/RemotePluginTest.php:101

1. Local users should not be returned when searching for empty string
2. The limit of the response should be respected
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
nickvergessenforce-pushed the bugfix/noid/fix-collaboration-result-size branch from f36663e to b30e035CompareFebruary 20, 2018 16:39
@nickvergessen

Copy link
Copy Markdown
MemberAuthor

Not really :(

Right, we modified RemotePlugin too....
Fixed now.

@blizzz
blizzz merged commit 8e5120c into masterFeb 20, 2018
@blizzz
blizzz deleted the bugfix/noid/fix-collaboration-result-size branch February 20, 2018 22:03
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@nickvergessen@MorrisJobke@rullzer@blizzz@juliusknorr