diff --git a/package-lock.json b/package-lock.json
index 2a971ee02b58..4e58eae320cb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "Rocket.Chat",
- "version": "0.64.0-develop",
+ "version": "0.65.0-develop",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -4683,6 +4683,7 @@
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
+ "optional": true,
"requires": {
"prr": "1.0.1"
}
@@ -10591,7 +10592,8 @@
"natives": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/natives/-/natives-1.1.3.tgz",
- "integrity": "sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g=="
+ "integrity": "sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g==",
+ "optional": true
},
"natural-compare": {
"version": "1.4.0",
@@ -12342,7 +12344,8 @@
"prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
- "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY="
+ "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
+ "optional": true
},
"pseudomap": {
"version": "1.0.2",
diff --git a/packages/rocketchat-lib/server/models/Subscriptions.js b/packages/rocketchat-lib/server/models/Subscriptions.js
index 6534764164de..12d40fedee78 100644
--- a/packages/rocketchat-lib/server/models/Subscriptions.js
+++ b/packages/rocketchat-lib/server/models/Subscriptions.js
@@ -6,7 +6,6 @@ class ModelSubscriptions extends RocketChat.models._Base {
this.tryEnsureIndex({ 'rid': 1, 'alert': 1, 'u._id': 1 });
this.tryEnsureIndex({ 'rid': 1, 'roles': 1 });
this.tryEnsureIndex({ 'u._id': 1, 'name': 1, 't': 1 });
- this.tryEnsureIndex({ 'u._id': 1, 'name': 1, 't': 1, 'code': 1 }, { unique: 1 });
this.tryEnsureIndex({ 'open': 1 });
this.tryEnsureIndex({ 'alert': 1 });
@@ -354,13 +353,13 @@ class ModelSubscriptions extends RocketChat.models._Base {
return this.update(query, update, { multi: true });
}
- updateNameByRoomId(roomId, name) {
+ updateDisplayNameByRoomId(roomId, fname) {
const query =
{ rid: roomId };
const update = {
$set: {
- name
+ fname
}
};
diff --git a/packages/rocketchat-livechat/.app/imports/client/visitor.js b/packages/rocketchat-livechat/.app/imports/client/visitor.js
index bb0613cb92e0..bbad77bdd2cc 100644
--- a/packages/rocketchat-livechat/.app/imports/client/visitor.js
+++ b/packages/rocketchat-livechat/.app/imports/client/visitor.js
@@ -66,7 +66,7 @@ export default {
msgStream.on(roomId, { token: this.getToken() }, (msg) => {
if (msg.t === 'command') {
Commands[msg.msg] && Commands[msg.msg]();
- } else if (msg.t !== 'livechat_video_call') {
+ } else if ( (msg.t !== 'livechat_video_call') && (msg.t !== 'au') ) {
ChatMessage.upsert({ _id: msg._id }, msg);
if (msg.t === 'livechat-close') {
diff --git a/packages/rocketchat-livechat/client/views/app/livechatCurrentChats.js b/packages/rocketchat-livechat/client/views/app/livechatCurrentChats.js
index 2a1ae39eec42..659784c4f33a 100644
--- a/packages/rocketchat-livechat/client/views/app/livechatCurrentChats.js
+++ b/packages/rocketchat-livechat/client/views/app/livechatCurrentChats.js
@@ -26,7 +26,7 @@ Template.livechatCurrentChats.helpers({
Template.livechatCurrentChats.events({
'click .row-link'() {
- FlowRouter.go('live', { code: this.code });
+ FlowRouter.go('live', { id: this._id });
},
'click .load-more'(event, instance) {
instance.limit.set(instance.limit.get() + 20);
diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorHistory.html b/packages/rocketchat-livechat/client/views/app/tabbar/visitorHistory.html
index 9963af801c0b..5d31eb9af9f6 100644
--- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorHistory.html
+++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorHistory.html
@@ -8,7 +8,7 @@
{{_ "Past_Chats"}}
diff --git a/packages/rocketchat-livechat/client/views/sideNav/livechat.js b/packages/rocketchat-livechat/client/views/sideNav/livechat.js
index a62542e5b9fc..4fa1c9a5bf10 100644
--- a/packages/rocketchat-livechat/client/views/sideNav/livechat.js
+++ b/packages/rocketchat-livechat/client/views/sideNav/livechat.js
@@ -31,7 +31,7 @@ Template.livechat.helpers({
return ChatSubscription.find(query, { sort: {
't': 1,
- 'name': 1
+ 'fname': 1
}});
},
diff --git a/packages/rocketchat-livechat/roomType.js b/packages/rocketchat-livechat/roomType.js
index 27eeb36c9584..e2a31e4e94a2 100644
--- a/packages/rocketchat-livechat/roomType.js
+++ b/packages/rocketchat-livechat/roomType.js
@@ -5,17 +5,17 @@ class LivechatRoomRoute extends RoomTypeRouteConfig {
constructor() {
super({
name: 'live',
- path: '/live/:code(\\d+)'
+ path: '/live/:id'
});
}
action(params) {
- openRoom('l', params.code);
+ openRoom('l', params.id);
}
link(sub) {
return {
- code: sub.code
+ id: sub.rid
};
}
}
@@ -36,15 +36,11 @@ class LivechatRoomType extends RoomTypeConfig {
}
findRoom(identifier) {
- return ChatRoom.findOne({code: parseInt(identifier)});
+ return ChatRoom.findOne({_id: identifier});
}
roomName(roomData) {
- if (!roomData.name) {
- return roomData.label;
- } else {
- return roomData.name;
- }
+ return roomData.name || roomData.fname || roomData.label;
}
condition() {
diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js
index e547a37c70b2..dd85b092e4db 100644
--- a/packages/rocketchat-livechat/server/lib/Livechat.js
+++ b/packages/rocketchat-livechat/server/lib/Livechat.js
@@ -297,7 +297,7 @@ RocketChat.Livechat = {
});
if (!_.isEmpty(guestData.name)) {
- return RocketChat.models.Rooms.setLabelByRoomId(roomData._id, guestData.name) && RocketChat.models.Subscriptions.updateNameByRoomId(roomData._id, guestData.name);
+ return RocketChat.models.Rooms.setNameById(roomData._id, roomData.name, guestData.name) && RocketChat.models.Subscriptions.updateDisplayNameByRoomId(roomData._id, guestData.name);
}
},
@@ -351,7 +351,6 @@ RocketChat.Livechat = {
unread: 1,
userMentions: 1,
groupMentions: 0,
- code: room.code,
u: {
_id: agent.agentId,
username: agent.username
@@ -412,7 +411,6 @@ RocketChat.Livechat = {
_id: room._id,
label: room.label,
topic: room.topic,
- code: room.code,
createdAt: room.ts,
lastMessageAt: room.lm,
tags: room.tags,
diff --git a/packages/rocketchat-livechat/server/lib/QueueMethods.js b/packages/rocketchat-livechat/server/lib/QueueMethods.js
index b7b600bbc46c..51f9e56bda42 100644
--- a/packages/rocketchat-livechat/server/lib/QueueMethods.js
+++ b/packages/rocketchat-livechat/server/lib/QueueMethods.js
@@ -14,14 +14,13 @@ RocketChat.QueueMethods = {
}
}
- const roomCode = RocketChat.models.Rooms.getNextLivechatRoomCode();
+ RocketChat.models.Rooms.updateLivechatRoomCount();
const room = _.extend({
_id: message.rid,
msgs: 1,
lm: new Date(),
- code: roomCode,
- label: guest.name || guest.username,
+ fname: (roomInfo && roomInfo.fname) || guest.name || guest.username,
// usernames: [agent.username, guest.username],
t: 'l',
ts: new Date(),
@@ -41,13 +40,12 @@ RocketChat.QueueMethods = {
}, roomInfo);
const subscriptionData = {
rid: message.rid,
- name: guest.name || guest.username,
+ fname: guest.name || guest.username,
alert: true,
open: true,
unread: 1,
userMentions: 1,
groupMentions: 0,
- code: roomCode,
u: {
_id: agent.agentId,
username: agent.username
@@ -55,7 +53,8 @@ RocketChat.QueueMethods = {
t: 'l',
desktopNotifications: 'all',
mobilePushNotifications: 'all',
- emailNotifications: 'all'
+ emailNotifications: 'all',
+ roles: ['owner']
};
RocketChat.models.Rooms.insert(room);
@@ -88,7 +87,7 @@ RocketChat.QueueMethods = {
throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
}
- const roomCode = RocketChat.models.Rooms.getNextLivechatRoomCode();
+ RocketChat.models.Rooms.updateLivechatRoomCount();
const agentIds = [];
@@ -105,7 +104,6 @@ RocketChat.QueueMethods = {
message: message.msg,
name: guest.name || guest.username,
ts: new Date(),
- code: roomCode,
department: guest.department,
agents: agentIds,
status: 'open',
@@ -121,8 +119,8 @@ RocketChat.QueueMethods = {
_id: message.rid,
msgs: 1,
lm: new Date(),
- code: roomCode,
label: guest.name || guest.username,
+ fname: guest.name || guest.username,
// usernames: [guest.username],
t: 'l',
ts: new Date(),
diff --git a/packages/rocketchat-livechat/server/methods/takeInquiry.js b/packages/rocketchat-livechat/server/methods/takeInquiry.js
index f1277d8d4ccc..8f1eed7c3fc7 100644
--- a/packages/rocketchat-livechat/server/methods/takeInquiry.js
+++ b/packages/rocketchat-livechat/server/methods/takeInquiry.js
@@ -26,7 +26,6 @@ Meteor.methods({
unread: 1,
userMentions: 1,
groupMentions: 0,
- code: inquiry.code,
u: {
_id: agent.agentId,
username: agent.username
diff --git a/packages/rocketchat-livechat/server/methods/webhookTest.js b/packages/rocketchat-livechat/server/methods/webhookTest.js
index c7961c89cc41..a40db1ee8de4 100644
--- a/packages/rocketchat-livechat/server/methods/webhookTest.js
+++ b/packages/rocketchat-livechat/server/methods/webhookTest.js
@@ -18,7 +18,6 @@ Meteor.methods({
_id: 'fasd6f5a4sd6f8a4sdf',
label: 'title',
topic: 'asiodojf',
- code: 123123,
createdAt: new Date(),
lastMessageAt: new Date(),
tags: [
diff --git a/packages/rocketchat-livechat/server/models/LivechatInquiry.js b/packages/rocketchat-livechat/server/models/LivechatInquiry.js
index 197bb4dbaf57..0b6315d64019 100644
--- a/packages/rocketchat-livechat/server/models/LivechatInquiry.js
+++ b/packages/rocketchat-livechat/server/models/LivechatInquiry.js
@@ -6,7 +6,6 @@ class LivechatInquiry extends RocketChat.models._Base {
this.tryEnsureIndex({ 'name': 1 }); // name of the inquiry (client name for now)
this.tryEnsureIndex({ 'message': 1 }); // message sent by the client
this.tryEnsureIndex({ 'ts': 1 }); // timestamp
- this.tryEnsureIndex({ 'code': 1 }); // (for routing)
this.tryEnsureIndex({ 'agents': 1}); // Id's of the agents who can see the inquiry (handle departments)
this.tryEnsureIndex({ 'status': 1}); // 'open', 'taken'
}
diff --git a/packages/rocketchat-livechat/server/models/Rooms.js b/packages/rocketchat-livechat/server/models/Rooms.js
index 19003d79cb8e..6786e71f3ac1 100644
--- a/packages/rocketchat-livechat/server/models/Rooms.js
+++ b/packages/rocketchat-livechat/server/models/Rooms.js
@@ -48,22 +48,16 @@ RocketChat.models.Rooms.findLivechat = function(filter = {}, offset = 0, limit =
return this.find(query, { sort: { ts: - 1 }, offset, limit });
};
-RocketChat.models.Rooms.findLivechatByCode = function(code, fields) {
- code = parseInt(code);
-
+RocketChat.models.Rooms.findLivechatById = function(_id, fields) {
const options = {};
if (fields) {
options.fields = fields;
}
- // if (this.useCache) {
- // return this.cache.findByIndex('t,code', ['l', code], options).fetch();
- // }
-
const query = {
t: 'l',
- code
+ _id
};
return this.findOne(query, options);
@@ -73,7 +67,7 @@ RocketChat.models.Rooms.findLivechatByCode = function(code, fields) {
* Get the next visitor name
* @return {string} The next visitor name
*/
-RocketChat.models.Rooms.getNextLivechatRoomCode = function() {
+RocketChat.models.Rooms.updateLivechatRoomCount = function() {
const settingsRaw = RocketChat.models.Settings.model.rawCollection();
const findAndModify = Meteor.wrapAsync(settingsRaw.findAndModify, settingsRaw);
@@ -162,10 +156,6 @@ RocketChat.models.Rooms.closeByRoomId = function(roomId, closeInfo) {
});
};
-RocketChat.models.Rooms.setLabelByRoomId = function(roomId, label) {
- return this.update({ _id: roomId }, { $set: { label } });
-};
-
RocketChat.models.Rooms.findOpenByAgent = function(userId) {
const query = {
open: true,
diff --git a/packages/rocketchat-livechat/server/models/indexes.js b/packages/rocketchat-livechat/server/models/indexes.js
index 6dbd49633926..1cd8fe3daf9f 100644
--- a/packages/rocketchat-livechat/server/models/indexes.js
+++ b/packages/rocketchat-livechat/server/models/indexes.js
@@ -1,5 +1,4 @@
Meteor.startup(function() {
- RocketChat.models.Rooms.tryEnsureIndex({ code: 1 });
RocketChat.models.Rooms.tryEnsureIndex({ open: 1 }, { sparse: 1 });
RocketChat.models.Users.tryEnsureIndex({ 'visitorEmails.address': 1 });
});
diff --git a/packages/rocketchat-livechat/server/startup.js b/packages/rocketchat-livechat/server/startup.js
index 1af415b4fbdc..1c131d052a82 100644
--- a/packages/rocketchat-livechat/server/startup.js
+++ b/packages/rocketchat-livechat/server/startup.js
@@ -1,6 +1,6 @@
Meteor.startup(() => {
- RocketChat.roomTypes.setRoomFind('l', (code) => {
- return RocketChat.models.Rooms.findLivechatByCode(code);
+ RocketChat.roomTypes.setRoomFind('l', (_id) => {
+ return RocketChat.models.Rooms.findLivechatById(_id);
});
RocketChat.authz.addRoomAccessValidator(function(room, user) {
diff --git a/packages/rocketchat-ui-sidenav/client/chatRoomItem.js b/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
index 50f22bdc25e2..3aa77d6005cd 100644
--- a/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
+++ b/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
@@ -1,12 +1,5 @@
Template.chatRoomItem.helpers({
roomData() {
- let {name} = this;
- const realNameForDirectMessages = RocketChat.settings.get('UI_Use_Real_Name') && this.t === 'd';
- const realNameForChannel = RocketChat.settings.get('UI_Allow_room_names_with_special_chars') && this.t !== 'd';
- if ((realNameForDirectMessages || realNameForChannel) && this.fname) {
- name = this.fname;
- }
-
let unread = false;
if (((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) && (this.unread > 0)) {
unread = this.unread;
@@ -30,7 +23,7 @@ Template.chatRoomItem.helpers({
avatar,
username : this.name,
route: RocketChat.roomTypes.getRouteLink(this.t, this),
- name,
+ name: RocketChat.roomTypes.getRoomName(this.t, this),
unread,
active,
archivedClass,
diff --git a/server/startup/migrations/v123.js b/server/startup/migrations/v123.js
new file mode 100644
index 000000000000..1be07abdbdb7
--- /dev/null
+++ b/server/startup/migrations/v123.js
@@ -0,0 +1,7 @@
+RocketChat.Migrations.add({
+ version: 123,
+ up() {
+ RocketChat.models.Subscriptions.tryDropIndex('u._id_1_name_1_t_1_code_1');
+ console.log('Fixing ChatSubscription u._id_1_name_1_t_1_code_1');
+ }
+});