Skip to content

Commit

Permalink
Merge pull request #18013 from nextcloud/bugfix/noid/fix-autocomplete…
Browse files Browse the repository at this point in the history
…-suggestions-with-numeric-users

Fix autocomplete suggestions with numeric users
  • Loading branch information
rullzer authored Nov 26, 2019
2 parents fe6dc80 + 06f97c0 commit 1fac817
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/comments/js/comments.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/src/commentstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
$comment.find('.avatar-name-wrapper').each(function() {
var $this = $(this)
var $inserted = $this.parent()
var userId = $this.find('.avatar').data('username')
var userId = $this.find('.avatar').data('username').toString()
if (userId.indexOf(' ') !== -1) {
$inserted.html('@"' + userId + '"')
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/Controller/AutoCompleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function prepareResultArray(array $results): array {
foreach ($results as $type => $subResult) {
foreach ($subResult as $result) {
$output[] = [
'id' => $result['value']['shareWith'],
'id' => (string) $result['value']['shareWith'],
'label' => $result['label'],
'source' => $type,
];
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Collaboration/Collaborators/UserPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[(string) $uid] = $userDisplayName;
}
}
} else {
Expand All @@ -80,7 +80,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {

foreach ($usersTmp as $user) {
if ($user->isEnabled()) { // Don't keep deactivated users
$users[$user->getUID()] = $user->getDisplayName();
$users[(string) $user->getUID()] = $user->getDisplayName();
}
}
}
Expand All @@ -94,6 +94,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$foundUserById = false;
$lowerSearch = strtolower($search);
foreach ($users as $uid => $userDisplayName) {
$uid = (string) $uid;
if (strtolower($uid) === $lowerSearch || strtolower($userDisplayName) === $lowerSearch) {
if (strtolower($uid) === $lowerSearch) {
$foundUserById = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0

$matchingUsers = [];
foreach ($groupUsers as $groupUser) {
$matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName();
$matchingUsers[(string) $groupUser->getUID()] = $groupUser->getDisplayName();
}
return $matchingUsers;
}
Expand Down

0 comments on commit 1fac817

Please sign in to comment.