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

dont show remote and email options if we have an exact match for local user email #16035

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

icewind1991
Copy link
Member

Signed-off-by: Robin Appelman robin@icewind.nl

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jun 21, 2019
@icewind1991 icewind1991 added this to the Nextcloud 17 milestone Jun 21, 2019
@wiswedel
Copy link
Contributor

ok: guest users aren't shown for sharebymail anymore
not ok: also valid federated share targets aren't assumed anymore

before:
image

image

after:
image

image

@icewind1991
Copy link
Member Author

imo, if a local user with a given email exists than it's highly unlikely that that email is also a fed share target that the user wants to share with. It already hides the fed. share option if the email is found in the user's address book

@wiswedel
Copy link
Contributor

It already hides the fed. share option if the email is found in the user's address book

Fair enough. Didn't know that

if a local user with a given email exists than it's highly unlikely that that email is also a fed share target that the user wants to share with.

Tricky to assume things like that. But I'm not going to open a general discussion about this. So let's go for your solution.

@wiswedel wiswedel self-requested a review June 24, 2019 03:52
@wiswedel
Copy link
Contributor

@rullzer @blizzz Can you please add your review? We need to get this on the road. Thx.

@MorrisJobke
Copy link
Member

I just tested again and for email addresses with exact match this is already the case since 15 at least. See also #15665 (comment)

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Tested and works 👍

@MorrisJobke
Copy link
Member

Those are the tests that fail:

[
'test',
true,
true,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, ['test1' => 'Test One']],
['xyz', 'test', 2, 0, []],
],
[],
[
['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
],
true,
false,
],
[
'test',
true,
false,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, ['test1' => 'Test One']],
['xyz', 'test', 2, 0, []],
],
[],
[],
true,
false,
],
[
'test',
true,
true,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
'test1' => 'Test One',
'test2' => 'Test Two',
]],
['xyz', 'test', 2, 0, [
'test1' => 'Test One',
'test2' => 'Test Two',
]],
],
[],
[
['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
],
[
'test',
true,
false,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
'test1' => 'Test One',
'test2' => 'Test Two',
]],
['xyz', 'test', 2, 0, [
'test1' => 'Test One',
'test2' => 'Test Two',
]],
],
[],
[],
true,
false,
],
[
'test',
true,
true,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
'test' => 'Test One',
]],
['xyz', 'test', 2, 0, [
'test2' => 'Test Two',
]],
],
[
['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
],
[
['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
],
[
'test',
true,
false,
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
'test' => 'Test One',
]],
['xyz', 'test', 2, 0, [
'test2' => 'Test Two',
]],
],
[
['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
],
[],
true,
false,
],

All of them do things like this:

				[
					['abc', 'test', 2, 0, ['test1' => 'Test One']],
					['xyz', 'test', 2, 0, []],
				],

as the user results instead of


				[
					$this->getUserMock('test0', 'Test'),
					$this->getUserMock('test1', 'Test One'),
					$this->getUserMock('test2', 'Test Two'),
				],

Thus I have no idea what the initial thoughts where behind this.

They are coming from somewhere here: https://github.com/nextcloud/server/blame/dd9e191d373217b2a07e4ac5b2cc294c0a6227a1/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php#L1272

@nickvergessen @icewind1991 Any idea how to "fix" them?

@nickvergessen
Copy link
Member

Seems like the tests where just not updated. It should return getUserMocks there as well.

@@ -71,7 +71,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
foreach ($userGroups as $userGroup) {
$usersTmp = $this->groupManager->displayNamesInGroup($userGroup, $search, $limit, $offset);
foreach ($usersTmp as $uid => $userDisplayName) {
$users[$uid] = $userDisplayName;
$users[$uid] = $this->userManager->get($uid);
Copy link
Member

@nickvergessen nickvergessen Jul 23, 2019

Choose a reason for hiding this comment

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

This needs adjustments in the tests.
It returns tons of null which of course later on dont have a getDisplayName() function, etc.

@rullzer rullzer removed this from the Nextcloud 17 milestone Aug 15, 2019
@skjnldsv
Copy link
Member

Bump?

@nickvergessen
Copy link
Member

Rebased and fixed the tests.
Let's get this in

This was referenced Dec 11, 2019
@blizzz
Copy link
Member

blizzz commented Dec 13, 2019

another rebase, as some failing tests are fixed on master meanwhile

@rullzer rullzer mentioned this pull request Dec 19, 2019
18 tasks
This was referenced Dec 27, 2019
@rullzer rullzer modified the milestones: Nextcloud 18, Nextcloud 19 Jan 7, 2020
@rullzer rullzer mentioned this pull request Apr 4, 2020
80 tasks
…l user email

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
Copy link
Member Author

rebased and fixed tests

@blizzz blizzz merged commit e9795d0 into master Apr 8, 2020
@blizzz blizzz deleted the share-search-hide-on-match branch April 8, 2020 22:08
@skjnldsv
Copy link
Member

Integration tests are broken

@skjnldsv
Copy link
Member

@danxuliu can you have a look, I'm really not familiar with the integration tests :(

@danxuliu
Copy link
Member

@danxuliu can you have a look, I'm really not familiar with the integration tests :(

The sharees integration test failures are legit. The problem is that now $userGroup->searchDisplayName is used, and it calls $backend->usersInGroup, which performs a case sensitive search. As the search string in the tests is sharee the user Sharee1 now is not found.

@skjnldsv
Copy link
Member

Yep, needed for 18!
/backport to stable18

@backportbot-nextcloud
Copy link

backport to stable18 in #20574

@nickvergessen
Copy link
Member

This breaks searching for users by displaynames when shareapi_only_share_with_group_members is on see #21451

@DanScharon
Copy link

unfortunately this doesn't work if the mail address is pasted with preceding or following whitespace(s).
We have users who do that and hit the first result (federated share) which fails, but they very often don't see the error message.

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.

9 participants