-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ignore non existing users when retrieving details of group members #13644
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,16 +203,20 @@ public function getGroupUsersDetails(string $groupId, string $search = '', int $ | |
| // Extract required number | ||
| $usersDetails = []; | ||
| foreach ($users as $user) { | ||
| /** @var IUser $user */ | ||
| $userId = (string) $user->getUID(); | ||
| $userData = $this->getUserData($userId); | ||
| // Do not insert empty entry | ||
| if(!empty($userData)) { | ||
| $usersDetails[$userId] = $userData; | ||
| } else { | ||
| // Logged user does not have permissions to see this user | ||
| // only showing its id | ||
| $usersDetails[$userId] = ['id' => $userId]; | ||
| try { | ||
| /** @var IUser $user */ | ||
| $userId = (string)$user->getUID(); | ||
| $userData = $this->getUserData($userId); | ||
| // Do not insert empty entry | ||
| if (!empty($userData)) { | ||
| $usersDetails[$userId] = $userData; | ||
| } else { | ||
| // Logged user does not have permissions to see this user | ||
| // only showing its id | ||
| $usersDetails[$userId] = ['id' => $userId]; | ||
| } | ||
| } catch(OCSNotFoundException $e) { | ||
| // continue if a users ceased to exist. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe at least log something?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user is not added to the list when this Exception pops up. Or do you mean something else?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, I don't really like having blank catches :p
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not an error condition, but a valid scenario. |
||
| } | ||
| } | ||
| return new DataResponse(['users' => $usersDetails]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throw the OCS not found exception? This is mainly osmething to throw when the middleware will handle it. The NoUserException seems perfectly valid here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is also done in line 95 (https://github.com/nextcloud/server/pull/13644/files/4915d64de8d0ee862f0fdc92fe9bf856f3e8cbe1#diff-4d20146890eb1004590c5327656f93bdR95), so it is consistent and catches both cases.