Skip to content

Add userdetails to ocs api - #8847

Merged
MorrisJobke merged 5 commits into
masterfrom
ocs-api-userdetails
Mar 20, 2018
Merged

Add userdetails to ocs api#8847
MorrisJobke merged 5 commits into
masterfrom
ocs-api-userdetails

Conversation

@skjnldsv

@skjnldsvskjnldsv commented Mar 16, 2018

Copy link
Copy Markdown
Member

To replace our current entry point used by the users list settings, I added some required data such as:

  • storageLocation
  • lastLogin
  • backend
  • subadmins groups list
  • Tests

Required by #8824

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsvskjnldsv added this to the Nextcloud 14 milestone Mar 16, 2018
@skjnldsvskjnldsv self-assigned this Mar 16, 2018
@skjnldsvskjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Mar 16, 2018
*
* @param string $search
* @param int $offset
* @return DataResponse

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.

There should be no need to define what is already present in code 😉

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.

You want me to remove the comment? :)

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.

Only the @param and @return statements as they are covered by the code already.

* @throws OCSException
*/
protected function getUserData(string $userId): array {
protected function getUserData(string $userId, bool $throw = true): array {

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.

You should catch the exception in getUsersDetails instead of adding variables that cause different behavior.

*/
public function getUsersDetails(string $search = '', $offset = null): DataResponse {
// Limit set to 25 for performance issues
$limit = 25;

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.

Since this is an API, I'd vote to add it as a paramter to the function.
If you know you deal with an instance which has only 30 users, there is no need to page the request

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.

Okay for me then :)


$users = [];
foreach ($subAdminOfGroups as $group) {
$users = array_merge($users, $this->groupManager->displayNamesInGroup($group, $search));

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.

use limit and offset here?

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.

Seems legit, the slice is already done in displayNamesInGroup...
I don't know why it wasn't like that already :)

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.

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@codecov

codecovBot commented Mar 16, 2018

Copy link
Copy Markdown

Codecov Report

Merging #8847 into master will decrease coverage by <.01%.
The diff coverage is 51.21%.

@@ Coverage Diff @@## master #8847 +/- ##
============================================
- Coverage 51.9% 51.89% -0.01% - Complexity 25269 25276 +7 
============================================
Files 1604 1604 Lines 94765 94792 +27 Branches 1377 1377 ============================================
+ Hits 49190 49197 +7 - Misses 45575 45595 +20
Impacted FilesCoverage ΔComplexity Δ
apps/provisioning_api/appinfo/routes.php0% <0%> (ø)0 <0> (ø)⬇️
...rovisioning_api/lib/Controller/UsersController.php77.2% <52.5%> (-3.98%)133 <16> (+7)
apps/files_trashbin/lib/Trashbin.php72.46% <0%> (-0.25%)136% <0%> (ø)
lib/private/Files/ObjectStore/SwiftFactory.php55% <0%> (+4%)37% <0%> (ø)⬇️

@skjnldsvskjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 16, 2018
@skjnldsv

Copy link
Copy Markdown
MemberAuthor

Okay, fixed and comment addressed! Please review :)

@skjnldsv

Copy link
Copy Markdown
MemberAuthor

Failures unrelated it seems!

@rullzerrullzer left a comment

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.

good stuff

throw new OCSException('Unknown error occurred', 102);
} else {
return new DataResponse($groups);
return new DataResponse($groups);;

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.

Please fix ;)

public function getUserSubAdminGroups(string $userId): DataResponse {
$groups = $this->getUserSubAdminGroupsData($userId);

if(!$groups) {

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.

Empty list would result in Unknown error occurred:

php > echo (![]) ? 'true' : 'false';
true

SHouldn't the error message a bit more specific? Or is this a known behavior?

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.

I have no idea, it was already there. Should we check for empty()?

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.

Hum in the end, No. We should just return an empty data. No errors.

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.

I guess it's fine to stay with the current way. 🙈

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.

With my last edits?

@MorrisJobke

Copy link
Copy Markdown
Member

beside that it looks good 👍

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv
skjnldsvforce-pushed the ocs-api-userdetails branch from a9bf964 to 16326efCompareMarch 16, 2018 15:09
@skjnldsvskjnldsv mentioned this pull request Mar 17, 2018
34 tasks
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv
skjnldsvforce-pushed the ocs-api-userdetails branch from 16326ef to 2465934CompareMarch 19, 2018 14:13
@skjnldsv
skjnldsv requested a review from blizzzMarch 20, 2018 08:47

@MorrisJobkeMorrisJobke left a comment

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.

Works 👍

@MorrisJobke
MorrisJobke merged commit 29c551c into masterMar 20, 2018
@MorrisJobke
MorrisJobke deleted the ocs-api-userdetails branch March 20, 2018 17:12
Sign up for freeto 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.

4 participants

@skjnldsv@MorrisJobke@rullzer@nickvergessen