Skip to content

Conversation

@schiessle
Copy link
Member

Check if global scale is enabled, in this case we should always query the lookup server. Further I improved the label of the result to look like User Name (uid@nextcloudserver)

@MorrisJobke
Copy link
Member

Further I improved the label of the result to look like User Name (uid@nextcloudserver)

I'm a bit unsure about this, but for now it's fine. We should rethink how to show email, remote, global scale, user and group share presentation anyways as we discussed it at the conf.

$isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
// if case of Global Scale we always search the lookup server
if ($isLookupServerEnabled !== 'yes' && $isGlobalScaleEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be like that?

$isLookupServerEnabled !== 'yes' && !$isGlobalScaleEnabled

Because it is:

neither lookup server is enabled nor global scale is enabled

Or did I miss something here?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, it worked during my tests as expected, but now I'm confused as well.. let me test it again

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@schiessle schiessle force-pushed the lookupserver-and-global-scale branch from 734d382 to 3fa13e7 Compare October 9, 2018 15:47
Signed-off-by: Bjoern Schiessle <[email protected]>
$isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
// if case of Global Scale we always search the lookup server
if ($isLookupServerEnabled !== 'yes' && !$isGlobalScaleEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

Would be a lot more readable if the === 'yes' is added to line 60 and then the if statement only holds !$isLookupServerEnabled && !$isGlobalScaleEnabled.

Sorry for nitpicking, but readable code is worth it IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea... will add it.

@MorrisJobke MorrisJobke added the 3. to review Waiting for reviews label Oct 10, 2018
$body = json_decode($response->getBody(), true);

foreach ($body as $lookup) {
$remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
Copy link
Member

Choose a reason for hiding this comment

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

try-catch


foreach ($body as $lookup) {
$remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
if ($this->currentUserRemote === $remote) continue;
Copy link
Member

Choose a reason for hiding this comment

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

newline + brackets

foreach ($body as $lookup) {
$remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
if ($this->currentUserRemote === $remote) continue;
$name = isset($lookup['name']['value']) ? $lookup['name']['value'] : '';
Copy link
Member

Choose a reason for hiding this comment

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

use ?? operator, see backport

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but honestly I consider the other one more readable so I will stick to it for now. All other points are addressed... Thanks for all the feedback!

Signed-off-by: Bjoern Schiessle <[email protected]>
@schiessle
Copy link
Member Author

@MorrisJobke @nickvergessen all comments are addressed

$this->config->expects($this->once())
$this->config->expects($this->at(0))
->method('getSystemValue')
->with('gs.enabled', false)
Copy link
Member

Choose a reason for hiding this comment

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

can we have tests with gs.enabled = true, too, please?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will produce the exact same results, because the lookup server is enabled in all test cases 😉 But I added another test (see last commit) which might do what you meant...

Copy link
Member

Choose a reason for hiding this comment

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

thanks :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@blizzz does this count as 👍 😉

Signed-off-by: Bjoern Schiessle <[email protected]>
Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

🐘

@schiessle schiessle merged commit 1ce8672 into master Oct 15, 2018
@schiessle schiessle deleted the lookupserver-and-global-scale branch October 15, 2018 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants