From b30d63bae2eead861c7c41bff6385ec0e9fafa0e Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Tue, 14 Jun 2016 22:08:31 +0100 Subject: [PATCH 01/79] Start changing usernames to actual names --- client/startup/defaultRoomTypes.coffee | 4 +++- packages/rocketchat-importer-hipchat/server.coffee | 2 +- packages/rocketchat-importer-slack/server.coffee | 2 +- .../rocketchat-lib/server/functions/sendMessage.coffee | 2 +- .../rocketchat-lib/server/methods/sendMessage.coffee | 2 +- packages/rocketchat-lib/server/models/Messages.coffee | 3 +++ packages/rocketchat-ui-message/message/message.html | 2 +- .../message/popup/messagePopupConfig.coffee | 4 +++- .../rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee | 2 +- packages/rocketchat-ui/views/app/room.coffee | 10 +++++++++- packages/rocketchat-ui/views/app/room.html | 3 +++ server/methods/addUserToRoom.coffee | 1 + server/publications/subscription.coffee | 1 + 13 files changed, 29 insertions(+), 9 deletions(-) diff --git a/client/startup/defaultRoomTypes.coffee b/client/startup/defaultRoomTypes.coffee index 88fb8b1958fb..701b8a82029e 100644 --- a/client/startup/defaultRoomTypes.coffee +++ b/client/startup/defaultRoomTypes.coffee @@ -41,7 +41,9 @@ RocketChat.roomTypes.add 'd', 20, $all: [identifier, user.username] return ChatRoom.findOne(query) roomName: (roomData) -> - return ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1 } })?.name + room = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } }) + console.log(room) + return room condition: -> return RocketChat.authz.hasAllPermission 'view-d-room' diff --git a/packages/rocketchat-importer-hipchat/server.coffee b/packages/rocketchat-importer-hipchat/server.coffee index 11403bd2674a..927a1f5dbae7 100644 --- a/packages/rocketchat-importer-hipchat/server.coffee +++ b/packages/rocketchat-importer-hipchat/server.coffee @@ -219,7 +219,7 @@ Importer.HipChat = class Importer.HipChat extends Importer.Base getRocketUser: (hipchatId) => for user in @users.users when user.user_id is hipchatId - return RocketChat.models.Users.findOneById user.rocketId, { fields: { username: 1 }} + return RocketChat.models.Users.findOneById user.rocketId, { fields: { username: 1, name: 1 }} convertHipChatMessageToRocketChat: (message) => if message? diff --git a/packages/rocketchat-importer-slack/server.coffee b/packages/rocketchat-importer-slack/server.coffee index da6dcb710d0f..4a3d6007632d 100644 --- a/packages/rocketchat-importer-slack/server.coffee +++ b/packages/rocketchat-importer-slack/server.coffee @@ -312,7 +312,7 @@ Importer.Slack = class Importer.Slack extends Importer.Base getRocketUser: (slackId) => for user in @users.users when user.id is slackId - return RocketChat.models.Users.findOneById user.rocketId, { fields: { username: 1 }} + return RocketChat.models.Users.findOneById user.rocketId, { fields: { username: 1, name: 1 }} convertSlackMessageToRocketChat: (message) => if message? diff --git a/packages/rocketchat-lib/server/functions/sendMessage.coffee b/packages/rocketchat-lib/server/functions/sendMessage.coffee index 063968cc72a6..a3b36909e7b9 100644 --- a/packages/rocketchat-lib/server/functions/sendMessage.coffee +++ b/packages/rocketchat-lib/server/functions/sendMessage.coffee @@ -5,7 +5,7 @@ RocketChat.sendMessage = (user, message, room) -> unless message.ts? message.ts = new Date() - message.u = _.pick user, ['_id','username'] + message.u = _.pick user, ['_id','username', 'name'] message.rid = room._id diff --git a/packages/rocketchat-lib/server/methods/sendMessage.coffee b/packages/rocketchat-lib/server/methods/sendMessage.coffee index f6b2e69c6d9c..d3eb64f2d98c 100644 --- a/packages/rocketchat-lib/server/methods/sendMessage.coffee +++ b/packages/rocketchat-lib/server/methods/sendMessage.coffee @@ -6,7 +6,7 @@ Meteor.methods if not Meteor.userId() throw new Meteor.Error('error-invalid-user', "Invalid user", { method: 'sendMessage' }) - user = RocketChat.models.Users.findOneById Meteor.userId(), fields: username: 1 + user = RocketChat.models.Users.findOneById Meteor.userId(), fields: { username: 1, name: 1 } room = Meteor.call 'canAccessRoom', message.rid, user._id diff --git a/packages/rocketchat-lib/server/models/Messages.coffee b/packages/rocketchat-lib/server/models/Messages.coffee index a1d6ced8c0af..c904b2b2cf84 100644 --- a/packages/rocketchat-lib/server/models/Messages.coffee +++ b/packages/rocketchat-lib/server/models/Messages.coffee @@ -276,6 +276,7 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base u: _id: user._id username: user.username + name: user.name groupable: false _.extend record, extraData @@ -284,6 +285,8 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base return record createUserJoinWithRoomIdAndUser: (roomId, user, extraData) -> + console.log('user join') + console.log(user) message = user.username return @createWithTypeRoomIdMessageAndUser 'uj', roomId, message, user, extraData diff --git a/packages/rocketchat-ui-message/message/message.html b/packages/rocketchat-ui-message/message/message.html index e440164119e7..474a6509bc73 100644 --- a/packages/rocketchat-ui-message/message/message.html +++ b/packages/rocketchat-ui-message/message/message.html @@ -24,7 +24,7 @@ {{#if alias}} {{else}} - + {{/if}} {{#each roleTags}} diff --git a/packages/rocketchat-ui-message/message/popup/messagePopupConfig.coffee b/packages/rocketchat-ui-message/message/popup/messagePopupConfig.coffee index 4a3db9801bb2..d3632a7b384d 100644 --- a/packages/rocketchat-ui-message/message/popup/messagePopupConfig.coffee +++ b/packages/rocketchat-ui-message/message/popup/messagePopupConfig.coffee @@ -8,7 +8,7 @@ Meteor.startup -> return filteredUsersMemory.remove({}) - messageUsers = RocketChat.models.Messages.find({rid: Session.get('openedRoom'), 'u.username': {$ne: Meteor.user().username}}, {fields: {'u.username': 1, ts: 1}, sort: {ts: -1}}).fetch() + messageUsers = RocketChat.models.Messages.find({rid: Session.get('openedRoom'), 'u.username': {$ne: Meteor.user().username}}, {fields: {'u.username': 1, 'u.name': 1, ts: 1}, sort: {ts: -1}}).fetch() uniqueMessageUsersControl = {} messageUsers.forEach (messageUser) -> if not uniqueMessageUsersControl[messageUser.u.username]? @@ -16,6 +16,7 @@ Meteor.startup -> filteredUsersMemory.upsert messageUser.u.username, _id: messageUser.u.username username: messageUser.u.username + name: messageUser.u.name status: Session.get('user_' + messageUser.u.username + '_status') or 'offline' ts: messageUser.ts @@ -43,6 +44,7 @@ Template.messagePopupConfig.helpers items.push _id: item.username username: item.username + name: item.name status: item.status # Get users of room diff --git a/packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee b/packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee index 6213ff94b8b4..18abd5cea9e1 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee +++ b/packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee @@ -12,7 +12,7 @@ Template.chatRoomItem.helpers return 'status-' + (Session.get('user_' + this.name + '_status') or 'offline') name: -> - return this.name + return this.fname or this.name roomIcon: -> return RocketChat.roomTypes.getIcon this.t diff --git a/packages/rocketchat-ui/views/app/room.coffee b/packages/rocketchat-ui/views/app/room.coffee index eff05bf4d4c2..ab8019be7aa9 100644 --- a/packages/rocketchat-ui/views/app/room.coffee +++ b/packages/rocketchat-ui/views/app/room.coffee @@ -43,7 +43,15 @@ Template.room.helpers roomData = Session.get('roomData' + this._id) return '' unless roomData - return RocketChat.roomTypes.getRoomName roomData?.t, roomData + room = RocketChat.roomTypes.getRoomName roomData?.t, roomData + return if typeof room is 'object' then room.fname or room.name else room + + secondaryName: -> + roomData = Session.get('roomData' + this._id) + return '' unless roomData + + room = RocketChat.roomTypes.getRoomName roomData?.t, roomData + return if typeof room is 'object' then room.name roomTopic: -> roomData = Session.get('roomData' + this._id) diff --git a/packages/rocketchat-ui/views/app/room.html b/packages/rocketchat-ui/views/app/room.html index 669cc4f7c582..8e00547164b9 100644 --- a/packages/rocketchat-ui/views/app/room.html +++ b/packages/rocketchat-ui/views/app/room.html @@ -14,6 +14,9 @@

{{/if}} {{roomName}} + {{#if secondaryName}} + @{{secondaryName}} + {{/if}} {{{RocketChatMarkdown roomTopic}}}

diff --git a/server/methods/addUserToRoom.coffee b/server/methods/addUserToRoom.coffee index 0b05a92925a4..0e84fbe43275 100644 --- a/server/methods/addUserToRoom.coffee +++ b/server/methods/addUserToRoom.coffee @@ -44,5 +44,6 @@ Meteor.methods u: _id: fromUser._id username: fromUser.username + name: fromUser.name return true diff --git a/server/publications/subscription.coffee b/server/publications/subscription.coffee index 7ad7accceca3..6531a6bb7b14 100644 --- a/server/publications/subscription.coffee +++ b/server/publications/subscription.coffee @@ -8,6 +8,7 @@ Meteor.publish 'subscription', -> ts: 1 ls: 1 name: 1 + fname: 1 rid: 1 code: 1 f: 1 From d8a26828c7ad7f7fd4d7c1dff9677e2586f45057 Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Sat, 23 Jul 2016 19:49:38 +0100 Subject: [PATCH 02/79] More changes to use actual names instead of usernames --- client/startup/defaultRoomTypes.coffee | 6 ++---- .../rocketchat-lib/server/models/Messages.coffee | 2 -- .../rocketchat-theme/assets/stylesheets/base.less | 14 +++++++++----- .../assets/stylesheets/utils/_colors.import.less | 8 ++++---- .../flex-tab/tabs/userInfo.html | 4 ++-- .../side-nav/accountBox.coffee | 2 ++ .../rocketchat-ui-sidenav/side-nav/accountBox.html | 2 +- .../side-nav/listDirectMessagesFlex.html | 4 ++-- .../side-nav/listDirectMessagesFlex.js | 8 ++++++-- .../rocketchat-ui/views/app/privateHistory.coffee | 2 +- packages/rocketchat-ui/views/app/room.html | 2 +- packages/rocketchat-ui/views/app/roomSearch.coffee | 2 +- packages/rocketchat-ui/views/app/userSearch.html | 2 +- server/methods/createDirectMessage.coffee | 2 ++ 14 files changed, 34 insertions(+), 26 deletions(-) diff --git a/client/startup/defaultRoomTypes.coffee b/client/startup/defaultRoomTypes.coffee index 701b8a82029e..a51db40a7c1c 100644 --- a/client/startup/defaultRoomTypes.coffee +++ b/client/startup/defaultRoomTypes.coffee @@ -25,7 +25,7 @@ RocketChat.roomTypes.add 'c', 10, RocketChat.roomTypes.add 'd', 20, template: 'directMessages' - icon: 'icon-at' + icon: 'icon-circle' route: name: 'direct' path: '/direct/:username' @@ -41,9 +41,7 @@ RocketChat.roomTypes.add 'd', 20, $all: [identifier, user.username] return ChatRoom.findOne(query) roomName: (roomData) -> - room = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } }) - console.log(room) - return room + return ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } }) condition: -> return RocketChat.authz.hasAllPermission 'view-d-room' diff --git a/packages/rocketchat-lib/server/models/Messages.coffee b/packages/rocketchat-lib/server/models/Messages.coffee index c904b2b2cf84..229dc87db1ed 100644 --- a/packages/rocketchat-lib/server/models/Messages.coffee +++ b/packages/rocketchat-lib/server/models/Messages.coffee @@ -285,8 +285,6 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base return record createUserJoinWithRoomIdAndUser: (roomId, user, extraData) -> - console.log('user join') - console.log(user) message = user.username return @createWithTypeRoomIdMessageAndUser 'uj', roomId, message, user, extraData diff --git a/packages/rocketchat-theme/assets/stylesheets/base.less b/packages/rocketchat-theme/assets/stylesheets/base.less index df75bbd91fe1..44685eb8834a 100644 --- a/packages/rocketchat-theme/assets/stylesheets/base.less +++ b/packages/rocketchat-theme/assets/stylesheets/base.less @@ -606,16 +606,16 @@ label.required:after { } .status-offline, -.icon-at.status-offline {} +.icon-circle.status-offline {} .status-online, -.icon-at.status-online {} +.icon-circle.status-online {} .status-busy, -.icon-at.status-busy {} +.icon-circle.status-busy {} .status-away, -.icon-at.status-away {} +.icon-circle.status-away {} // TODO -- Refactor favorite styles and logic; .favorite-room {} @@ -1614,7 +1614,7 @@ a.github-fork { font-size: 22px; font-weight: 500; line-height: 29px; - .icon-at, + .icon-circle, .icon-hash, .icon-lock { margin-right: -7px; @@ -2411,6 +2411,10 @@ a.github-fork { display: inline-block; } } + .secondary-name { + color: #666; + font-size: 15px; + } } .messages-box { diff --git a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less index 15c270af00a0..fadc53c47393 100755 --- a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less +++ b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less @@ -175,22 +175,22 @@ label.required:after { } .status-offline, -.icon-at.status-offline { +.icon-circle.status-offline { color: @status-offline; } .status-online, -.icon-at.status-online { +.icon-circle.status-online { color: @status-online; } .status-busy, -.icon-at.status-busy { +.icon-circle.status-busy { color: @status-busy; } .status-away, -.icon-at.status-away { +.icon-circle.status-away { color: @status-away; } diff --git a/packages/rocketchat-ui-flextab/flex-tab/tabs/userInfo.html b/packages/rocketchat-ui-flextab/flex-tab/tabs/userInfo.html index 6c6e528b09e5..815d4ac2bb34 100644 --- a/packages/rocketchat-ui-flextab/flex-tab/tabs/userInfo.html +++ b/packages/rocketchat-ui-flextab/flex-tab/tabs/userInfo.html @@ -11,8 +11,8 @@ {{> avatar username=username}}
-

{{username}}

-

{{name}}

+

{{name}}

+

@{{username}}

{{#each roleTags}} {{description}} diff --git a/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee b/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee index 7d5e89e70cb5..1f5ec602e479 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee +++ b/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee @@ -2,6 +2,7 @@ Template.accountBox.helpers myUserInfo: -> visualStatus = "online" username = Meteor.user()?.username + name = Meteor.user()?.name switch Session.get('user_' + username + '_status') when "away" visualStatus = t("away") @@ -15,6 +16,7 @@ Template.accountBox.helpers visualStatus: visualStatus _id: Meteor.userId() username: username + fname: name } showAdminOption: -> diff --git a/packages/rocketchat-ui-sidenav/side-nav/accountBox.html b/packages/rocketchat-ui-sidenav/side-nav/accountBox.html index 5f79fea9a0b4..7e392b838304 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/accountBox.html +++ b/packages/rocketchat-ui-sidenav/side-nav/accountBox.html @@ -7,7 +7,7 @@ {{> avatar username=username}}

-

{{username}}

+

{{fname}}

{{/if}} diff --git a/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.html b/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.html index 50fdf94ed230..ab96eb01c5d8 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.html +++ b/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.html @@ -28,8 +28,8 @@

{{_ "List_of_Direct_Messages"}}

{{#each rooms}}
  • - - {{name}} + + {{fname}} {{#if hidden}} diff --git a/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.js b/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.js index 3d4d018ffdb7..422f51923065 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.js +++ b/packages/rocketchat-ui-sidenav/side-nav/listDirectMessagesFlex.js @@ -67,7 +67,7 @@ Template.listDirectMessagesFlex.onCreated(function() { this.roomsList = new ReactiveVar([]); this.autorun(() => { this.hasMore.set(true); - let options = { fields: { name: 1 } }; + let options = { fields: { name: 1, fname: 1 } }; if (_.isNumber(this.limit.get())) { options.limit = this.limit.get(); } @@ -83,7 +83,11 @@ Template.listDirectMessagesFlex.onCreated(function() { } let query = { t: 'd' }; if (s.trim(this.nameFilter.get())) { - query.name = new RegExp(s.trim(s.escapeRegExp(this.nameFilter.get())), 'i'); + filter = new RegExp(s.trim(s.escapeRegExp(this.nameFilter.get())), 'i'); + query.$or = [ + { name: filter }, + { fname: filter } + ]; } this.roomsList.set(RocketChat.models.Subscriptions.find(query, options).fetch()); diff --git a/packages/rocketchat-ui/views/app/privateHistory.coffee b/packages/rocketchat-ui/views/app/privateHistory.coffee index b59fdc7c23e6..2656bea5d52a 100644 --- a/packages/rocketchat-ui/views/app/privateHistory.coffee +++ b/packages/rocketchat-ui/views/app/privateHistory.coffee @@ -18,7 +18,7 @@ Template.privateHistory.helpers type: -> switch this.t - when 'd' then 'icon-at' + when 'd' then 'icon-circle' when 'c' then 'icon-hash' when 'p' then 'icon-lock' diff --git a/packages/rocketchat-ui/views/app/room.html b/packages/rocketchat-ui/views/app/room.html index 1ccb59328ff6..c62c0329bb68 100644 --- a/packages/rocketchat-ui/views/app/room.html +++ b/packages/rocketchat-ui/views/app/room.html @@ -15,7 +15,7 @@

    {{roomName}} {{#if secondaryName}} - @{{secondaryName}} + @{{secondaryName}} {{/if}} {{{RocketChatMarkdown roomTopic}}}

    diff --git a/packages/rocketchat-ui/views/app/roomSearch.coffee b/packages/rocketchat-ui/views/app/roomSearch.coffee index 5e8800500850..170d6ef7c094 100644 --- a/packages/rocketchat-ui/views/app/roomSearch.coffee +++ b/packages/rocketchat-ui/views/app/roomSearch.coffee @@ -1,6 +1,6 @@ Template.roomSearch.helpers roomIcon: -> - return 'icon-at' if this.type is 'u' + return 'icon-circle' if this.type is 'u' if this.type is 'r' return RocketChat.roomTypes.getIcon this.t diff --git a/packages/rocketchat-ui/views/app/userSearch.html b/packages/rocketchat-ui/views/app/userSearch.html index 180a40b673b7..24471e2485a2 100644 --- a/packages/rocketchat-ui/views/app/userSearch.html +++ b/packages/rocketchat-ui/views/app/userSearch.html @@ -1,5 +1,5 @@