From 06b0fb7fedbbb5b392982422fe0b6e0895480ec5 Mon Sep 17 00:00:00 2001 From: Alexander Birkner Date: Sat, 21 May 2016 17:19:53 +0200 Subject: [PATCH 1/2] User search for username and name instead of only username --- .../rocketchat-lib/server/models/Users.coffee | 19 +++++++++++++++---- .../side-nav/directMessagesFlex.coffee | 6 +++--- server/publications/userAutocomplete.coffee | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/rocketchat-lib/server/models/Users.coffee b/packages/rocketchat-lib/server/models/Users.coffee index 6a79b181d477..ce57023e2394 100644 --- a/packages/rocketchat-lib/server/models/Users.coffee +++ b/packages/rocketchat-lib/server/models/Users.coffee @@ -84,16 +84,24 @@ RocketChat.models.Users = new class extends RocketChat.models._Base return @find query, options - findActiveByUsernameRegexWithExceptions: (username, exceptions = [], options = {}) -> + findActiveByUsernameOrNameRegexWithExceptions: (searchTerm, exceptions = [], options = {}) -> if not _.isArray exceptions exceptions = [ exceptions ] - usernameRegex = new RegExp username, "i" + termRegex = new RegExp searchTerm, "i" query = $and: [ { active: true } - { username: { $nin: exceptions } } - { username: usernameRegex } + {'$or': [ + {'$and': [ + { username: { $nin: exceptions } } + { username: termRegex } + ]} + {'$and': [ + { name: { $nin: exceptions } } + { name: termRegex } + ]} + ]} ] type: $in: ['user', 'bot'] @@ -150,6 +158,9 @@ RocketChat.models.Users = new class extends RocketChat.models._Base return @find(query, options)?.fetch?()?[0]?.lastLogin + getDisplayName: (_id) -> + return "display name" + findUsersByUsernames: (usernames, options) -> query = username: diff --git a/packages/rocketchat-ui-sidenav/side-nav/directMessagesFlex.coffee b/packages/rocketchat-ui-sidenav/side-nav/directMessagesFlex.coffee index fd08fc87d329..34486a785a48 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/directMessagesFlex.coffee +++ b/packages/rocketchat-ui-sidenav/side-nav/directMessagesFlex.coffee @@ -16,11 +16,11 @@ Template.directMessagesFlex.helpers noMatchTemplate: Template.userSearchEmpty matchAll: true filter: - exceptions: [Meteor.user().username] + exceptions: [Meteor.user().username, Meteor.user().name] selector: (match) -> - return { username: match } + return { term: match } sort: 'username' - } + }, ] } diff --git a/server/publications/userAutocomplete.coffee b/server/publications/userAutocomplete.coffee index 1be9ad7d5bfc..d3d1bd4252c3 100644 --- a/server/publications/userAutocomplete.coffee +++ b/server/publications/userAutocomplete.coffee @@ -15,7 +15,7 @@ Meteor.publish 'userAutocomplete', (selector) -> exceptions = selector.exceptions or [] - cursorHandle = RocketChat.models.Users.findActiveByUsernameRegexWithExceptions(selector.username, exceptions, options).observeChanges + cursorHandle = RocketChat.models.Users.findActiveByUsernameOrNameRegexWithExceptions(selector.term, exceptions, options).observeChanges added: (_id, record) -> pub.added("autocompleteRecords", _id, record) changed: (_id, record) -> From 62d18ceeed6c6d07c9153e6310f2e290011bc593 Mon Sep 17 00:00:00 2001 From: Alexander Birkner Date: Sat, 21 May 2016 17:40:13 +0200 Subject: [PATCH 2/2] Added the command to delete the current room --- .../client/views/permissionsRole.coffee | 2 +- .../client/views/mailMessagesInstructions.coffee | 2 +- packages/rocketchat-livechat/app/client/views/message.html | 2 +- .../rocketchat-ui-flextab/flex-tab/tabs/membersList.coffee | 4 ++-- packages/rocketchat-ui-message/message/message.html | 2 +- .../rocketchat-ui-sidenav/side-nav/createChannelFlex.coffee | 2 +- .../rocketchat-ui-sidenav/side-nav/privateGroupsFlex.coffee | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/rocketchat-authorization/client/views/permissionsRole.coffee b/packages/rocketchat-authorization/client/views/permissionsRole.coffee index b2636fa18a9a..d39e1bbb638a 100644 --- a/packages/rocketchat-authorization/client/views/permissionsRole.coffee +++ b/packages/rocketchat-authorization/client/views/permissionsRole.coffee @@ -60,7 +60,7 @@ Template.permissionsRole.helpers filter: exceptions: Template.instance().usersInRole.get()?.fetch() selector: (match) -> - return { username: match } + return { term: match } sort: 'username' } ] diff --git a/packages/rocketchat-channel-settings-mail-messages/client/views/mailMessagesInstructions.coffee b/packages/rocketchat-channel-settings-mail-messages/client/views/mailMessagesInstructions.coffee index 340e100de6e2..7d3e047ef1ba 100644 --- a/packages/rocketchat-channel-settings-mail-messages/client/views/mailMessagesInstructions.coffee +++ b/packages/rocketchat-channel-settings-mail-messages/client/views/mailMessagesInstructions.coffee @@ -23,7 +23,7 @@ Template.mailMessagesInstructions.helpers filter: exceptions: Template.instance().selectedUsers.get() selector: (match) -> - return { username: match } + return { term: match } sort: 'username' } ] diff --git a/packages/rocketchat-livechat/app/client/views/message.html b/packages/rocketchat-livechat/app/client/views/message.html index 357dd077df9c..5340b77e1308 100644 --- a/packages/rocketchat-livechat/app/client/views/message.html +++ b/packages/rocketchat-livechat/app/client/views/message.html @@ -9,7 +9,7 @@ {{/if}}
- {{{body}}} + {{{body}}} dasds
diff --git a/packages/rocketchat-ui-flextab/flex-tab/tabs/membersList.coffee b/packages/rocketchat-ui-flextab/flex-tab/tabs/membersList.coffee index a990245f4bb8..438de4943f63 100644 --- a/packages/rocketchat-ui-flextab/flex-tab/tabs/membersList.coffee +++ b/packages/rocketchat-ui-flextab/flex-tab/tabs/membersList.coffee @@ -72,9 +72,9 @@ Template.membersList.helpers noMatchTemplate: Template.userSearchEmpty matchAll: true filter: - exceptions: [Meteor.user().username] + exceptions: [Meteor.user().username, Meteor.user().name] selector: (match) -> - return { username: match } + return { term: match } sort: 'username' } ] diff --git a/packages/rocketchat-ui-message/message/message.html b/packages/rocketchat-ui-message/message/message.html index 895831b9dd86..12087fd8c87e 100644 --- a/packages/rocketchat-ui-message/message/message.html +++ b/packages/rocketchat-ui-message/message/message.html @@ -4,7 +4,7 @@ {{#if avatarFromUsername}} {{else}} -