From 2fb6d12f7323dbe282e6e84cf0a2735ce3eb6754 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 26 Feb 2018 15:22:15 -0300 Subject: [PATCH 01/17] Fix livechat routes to allow inviting other agents to the same chat. --- .../.app/imports/client/visitor.js | 2 +- .../client/views/app/livechatCurrentChats.js | 2 +- .../client/views/sideNav/livechat.js | 2 +- packages/rocketchat-livechat/roomType.js | 8 ++++---- .../server/lib/QueueMethods.js | 3 +++ .../rocketchat-livechat/server/models/Rooms.js | 15 +++++++++++++++ packages/rocketchat-livechat/server/startup.js | 4 ++-- 7 files changed, 27 insertions(+), 9 deletions(-) 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/sideNav/livechat.js b/packages/rocketchat-livechat/client/views/sideNav/livechat.js index 659850b88319..15bccfe076db 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 5a012f7edf5d..94bfe76897c0 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,7 +36,7 @@ class LivechatRoomType extends RoomTypeConfig { } findRoom(identifier) { - return ChatRoom.findOne({code: parseInt(identifier)}); + return ChatRoom.findOne({_id: identifier}); } roomName(roomData) { diff --git a/packages/rocketchat-livechat/server/lib/QueueMethods.js b/packages/rocketchat-livechat/server/lib/QueueMethods.js index b7b600bbc46c..148a7816cda3 100644 --- a/packages/rocketchat-livechat/server/lib/QueueMethods.js +++ b/packages/rocketchat-livechat/server/lib/QueueMethods.js @@ -22,6 +22,8 @@ RocketChat.QueueMethods = { lm: new Date(), code: roomCode, label: guest.name || guest.username, + name: (roomInfo && roomInfo.name) || guest.name || guest.username, + fname: (roomInfo && roomInfo.fname) || guest.name || guest.username, // usernames: [agent.username, guest.username], t: 'l', ts: new Date(), @@ -123,6 +125,7 @@ RocketChat.QueueMethods = { 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/models/Rooms.js b/packages/rocketchat-livechat/server/models/Rooms.js index 19003d79cb8e..023285c0fae8 100644 --- a/packages/rocketchat-livechat/server/models/Rooms.js +++ b/packages/rocketchat-livechat/server/models/Rooms.js @@ -69,6 +69,21 @@ RocketChat.models.Rooms.findLivechatByCode = function(code, fields) { return this.findOne(query, options); }; +RocketChat.models.Rooms.findLivechatById = function(_id, fields) { + const options = {}; + + if (fields) { + options.fields = fields; + } + + const query = { + t: 'l', + _id + }; + + return this.findOne(query, options); +}; + /** * Get the next visitor name * @return {string} The next visitor name 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) { From 41e7cbd662049bc074f8c96cfeced70e310e4932 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 26 Feb 2018 16:39:19 -0300 Subject: [PATCH 02/17] Fix indentation tabs. --- .../server/lib/QueueMethods.js | 6 +++--- .../rocketchat-livechat/server/models/Rooms.js | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/rocketchat-livechat/server/lib/QueueMethods.js b/packages/rocketchat-livechat/server/lib/QueueMethods.js index 148a7816cda3..0b5d204fbe97 100644 --- a/packages/rocketchat-livechat/server/lib/QueueMethods.js +++ b/packages/rocketchat-livechat/server/lib/QueueMethods.js @@ -22,8 +22,8 @@ RocketChat.QueueMethods = { lm: new Date(), code: roomCode, label: guest.name || guest.username, - name: (roomInfo && roomInfo.name) || guest.name || guest.username, - fname: (roomInfo && roomInfo.fname) || guest.name || guest.username, + name: (roomInfo && roomInfo.name) || guest.name || guest.username, + fname: (roomInfo && roomInfo.fname) || guest.name || guest.username, // usernames: [agent.username, guest.username], t: 'l', ts: new Date(), @@ -125,7 +125,7 @@ RocketChat.QueueMethods = { lm: new Date(), code: roomCode, label: guest.name || guest.username, - fname: guest.name || guest.username, + fname: guest.name || guest.username, // usernames: [guest.username], t: 'l', ts: new Date(), diff --git a/packages/rocketchat-livechat/server/models/Rooms.js b/packages/rocketchat-livechat/server/models/Rooms.js index 023285c0fae8..43c438c8540c 100644 --- a/packages/rocketchat-livechat/server/models/Rooms.js +++ b/packages/rocketchat-livechat/server/models/Rooms.js @@ -70,18 +70,18 @@ RocketChat.models.Rooms.findLivechatByCode = function(code, fields) { }; RocketChat.models.Rooms.findLivechatById = function(_id, fields) { - const options = {}; + const options = {}; - if (fields) { - options.fields = fields; - } + if (fields) { + options.fields = fields; + } - const query = { - t: 'l', - _id - }; + const query = { + t: 'l', + _id + }; - return this.findOne(query, options); + return this.findOne(query, options); }; /** From 587ffdaa8456c6f864314312ad5720655331603a Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 28 Feb 2018 11:21:04 -0300 Subject: [PATCH 03/17] Started working on send visitor navigation history as a message to agents. --- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 1 + packages/rocketchat-livechat/config.js | 7 ++++ .../server/lib/Livechat.js | 36 +++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 706fefe310ed..6bf3c5fd9f82 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1319,6 +1319,7 @@ "Mobile_Notifications_Default_Alert": "Mobile Notifications Default Alert", "Monday": "Monday", "Monitor_history_for_changes_on": "Monitor History for Changes on", + "Send_Visitor_navigation_history_as_a_message": "Send Visitor Navigation History as a Message", "More_channels": "More channels", "More_direct_messages": "More direct messages", "More_groups": "More private groups", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index d869357e085b..5b2f52e9b6b4 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -777,6 +777,7 @@ "Meta_robots": "Robots", "minutes": "minutos", "Monitor_history_for_changes_on": "Monitorar mudanças de histórico para", + "Send_Visitor_navigation_history_as_a_message": "Enviar histórico de navegação do visitante como mensagem", "More_channels": "Mais canais", "More_direct_messages": "Mais mensagens diretas", "More_groups": "Mais grupos privados", diff --git a/packages/rocketchat-livechat/config.js b/packages/rocketchat-livechat/config.js index 3a7815a4d6e8..2975d56fc5d2 100644 --- a/packages/rocketchat-livechat/config.js +++ b/packages/rocketchat-livechat/config.js @@ -186,6 +186,13 @@ Meteor.startup(function() { ] }); + RocketChat.settings.add('Livechat_Visitor_navigation_as_a_message', true, { + type: 'boolean', + group: 'Livechat', + public: true, + i18nLabel: 'Send_Visitor_navigation_history_as_a_message' + }); + RocketChat.settings.add('Livechat_enable_office_hours', false, { type: 'boolean', group: 'Livechat', diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js index 99079cb7f6b9..4ed0af80f24d 100644 --- a/packages/rocketchat-livechat/server/lib/Livechat.js +++ b/packages/rocketchat-livechat/server/lib/Livechat.js @@ -313,6 +313,42 @@ RocketChat.Livechat = { savePageHistory(token, pageInfo) { if (pageInfo.change === RocketChat.Livechat.historyMonitorType) { + + RocketChat.models.Rooms.findByVisitorToken(token).forEach((room) => { + + const users = Meteor.users.find({ + username: { + $in: room.usernames + } + }); + + if (users.count() === 0) { + //return; + } + + users.forEach(function(user) { + + RocketChat.Notifications.notifyUser(user._id, 'message', { + _id: Random.id(), + rid: room._id, + ts: new Date, + msg: TAPi18n.__(pageInfo.title, {}, user.language) + }); + + /* + RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', { + _id: Random.id(), + rid: room._id, + ts: new Date, + msg: TAPi18n.__('Visitor Navigation', { + postProcess: 'sprintf', + sprintf: [user.username] + }, currentUser.language) + }) + ;*/ + }); + }); + return RocketChat.models.LivechatPageVisited.saveByToken(token, pageInfo); } From 460b76bb8674059ed4a1776f3b13f415654f4e80 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Fri, 9 Mar 2018 19:01:15 -0300 Subject: [PATCH 04/17] - Sending the navigation history of the visitor as a message; - Created a setting to manage it (enabled by default) - Created a migration to move navigation historys to messages collection --- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 1 + .../rocketchat-lib/server/models/Messages.js | 11 ++++ .../.app/client/lib/hooks.js | 2 +- .../.app/client/views/messages.js | 2 +- .../.app/imports/client/visitor.js | 4 +- .../client/collections/LivechatMessage.js | 1 + .../views/app/tabbar/visitorNavigation.html | 4 +- .../views/app/tabbar/visitorNavigation.js | 8 +-- packages/rocketchat-livechat/messageTypes.js | 5 ++ packages/rocketchat-livechat/package.js | 2 + .../server/lib/Livechat.js | 50 +++++++------------ .../server/methods/pageVisited.js | 4 +- .../server/methods/registerGuest.js | 3 -- .../server/methods/sendTranscript.js | 2 +- .../server/methods/setDepartmentForVisitor.js | 3 -- .../server/models/LivechatMessage.js | 10 ++++ .../server/publications/visitorPageVisited.js | 5 +- server/startup/migrations/v108.js | 47 +++++++++++++++++ 19 files changed, 113 insertions(+), 52 deletions(-) create mode 100644 packages/rocketchat-livechat/client/collections/LivechatMessage.js create mode 100644 packages/rocketchat-livechat/server/models/LivechatMessage.js create mode 100644 server/startup/migrations/v108.js diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 6bf3c5fd9f82..b10bb96badeb 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1361,6 +1361,7 @@ "New_Trigger": "New Trigger", "New_version_available_(s)": "New version available (%s)", "New_videocall_request": "New Video Call Request", + "New_visitor_navigation": "New Visitor Navigation", "No_available_agents_to_transfer": "No available agents to transfer", "No_channel_with_name_%s_was_found": "No channel with name \"%s\" was found!", "No_channels_yet": "You aren't part of any channel yet", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 5b2f52e9b6b4..bcf4e8f6c555 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -807,6 +807,7 @@ "New_Room_Notification": "Notificação de nova sala", "New_Trigger": "Novo Gatilho", "New_videocall_request": "Nova requisição de chamada de vídeo", + "New_visitor_navigation": "Nova Navegação do visitante", "No_available_agents_to_transfer": "Nenhum agente disponível para transferir", "No_channel_with_name_%s_was_found": "Nenhum canal com nome \"%s\" foi encontrado!", "No_channels_yet": "Você não faz parte de nenhum canal ainda.", diff --git a/packages/rocketchat-lib/server/models/Messages.js b/packages/rocketchat-lib/server/models/Messages.js index a52fcdaa1843..34573e223f7b 100644 --- a/packages/rocketchat-lib/server/models/Messages.js +++ b/packages/rocketchat-lib/server/models/Messages.js @@ -284,6 +284,17 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base { return this.findOne(query); } + findByRoomIdAndType(roomId, type, options) { + const query = { + rid: roomId, + t: type, + }; + + if (options == null) { options = {}; } + + return this.find(query, options); + } + getLastVisibleMessageSentWithNoTypeByRoomId(rid, messageId) { const query = { rid, diff --git a/packages/rocketchat-livechat/.app/client/lib/hooks.js b/packages/rocketchat-livechat/.app/client/lib/hooks.js index 3a525c34cf5d..89436156dc19 100644 --- a/packages/rocketchat-livechat/.app/client/lib/hooks.js +++ b/packages/rocketchat-livechat/.app/client/lib/hooks.js @@ -7,7 +7,7 @@ const api = { Triggers.processRequest(info); } - Meteor.call('livechat:pageVisited', visitor.getToken(), info); + Meteor.call('livechat:pageVisited', visitor.getToken(), visitor.getRoom(), info); }, setCustomField(key, value, overwrite = true) { diff --git a/packages/rocketchat-livechat/.app/client/views/messages.js b/packages/rocketchat-livechat/.app/client/views/messages.js index 9d298fa207cf..4c125cba579c 100644 --- a/packages/rocketchat-livechat/.app/client/views/messages.js +++ b/packages/rocketchat-livechat/.app/client/views/messages.js @@ -7,7 +7,7 @@ Template.messages.helpers({ return ChatMessage.find({ rid: visitor.getRoom(), t: { - '$ne': 't' + '$nin': ['t', 'livechat_navigation_history'] } }, { sort: { diff --git a/packages/rocketchat-livechat/.app/imports/client/visitor.js b/packages/rocketchat-livechat/.app/imports/client/visitor.js index bbad77bdd2cc..568ece8cd3a3 100644 --- a/packages/rocketchat-livechat/.app/imports/client/visitor.js +++ b/packages/rocketchat-livechat/.app/imports/client/visitor.js @@ -1,3 +1,4 @@ +import _ from 'underscore'; /* globals Commands */ const msgStream = new Meteor.Streamer('room-messages'); @@ -63,10 +64,11 @@ export default { this.roomSubscribed = roomId; + const msgTypesNotDisplayed = ['livechat_video_call', 'livechat_navigation_history', 'au']; msgStream.on(roomId, { token: this.getToken() }, (msg) => { if (msg.t === 'command') { Commands[msg.msg] && Commands[msg.msg](); - } else if ( (msg.t !== 'livechat_video_call') && (msg.t !== 'au') ) { + } else if (!_.contains(msgTypesNotDisplayed, msg.t)) { ChatMessage.upsert({ _id: msg._id }, msg); if (msg.t === 'livechat-close') { diff --git a/packages/rocketchat-livechat/client/collections/LivechatMessage.js b/packages/rocketchat-livechat/client/collections/LivechatMessage.js new file mode 100644 index 000000000000..456375d8575d --- /dev/null +++ b/packages/rocketchat-livechat/client/collections/LivechatMessage.js @@ -0,0 +1 @@ +this.LivechatMessage = new Mongo.Collection('rocketchat_message'); diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.html b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.html index b6fc919ce506..be44263dd093 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.html +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.html @@ -8,8 +8,8 @@

{{_ "Navigation_History"}}

{{else}}
diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js index 06a62d8a7d0d..08b4fbd955f1 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js @@ -5,16 +5,16 @@ Template.visitorNavigation.helpers({ return !Template.instance().pageVisited.ready(); }, - pageVisited() { + pages() { const room = ChatRoom.findOne({ _id: this.rid }, { fields: { 'v.token': 1 } }); - if (room && room.v && room.v.token) { - return LivechatPageVisited.find({ token: room.v.token }, { sort: { ts: -1 } }); + if (room) { + return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history', $or: [{ _shared: { $exists: false }}, { _shared: true }]}, { sort: { ts: -1 } }); } }, pageTitle() { - return this.page.title || t('Empty_title'); + return this.navigation.page.title || t('Empty_title'); }, accessDateTime() { diff --git a/packages/rocketchat-livechat/messageTypes.js b/packages/rocketchat-livechat/messageTypes.js index 670ae5b5b8c2..606eb5f8ce16 100644 --- a/packages/rocketchat-livechat/messageTypes.js +++ b/packages/rocketchat-livechat/messageTypes.js @@ -1,3 +1,8 @@ +RocketChat.MessageTypes.registerType({ + id: 'livechat_navigation_history', + system: true +}); + RocketChat.MessageTypes.registerType({ id: 'livechat_video_call', system: true, diff --git a/packages/rocketchat-livechat/package.js b/packages/rocketchat-livechat/package.js index c0f0511a44d9..de106b85ed47 100644 --- a/packages/rocketchat-livechat/package.js +++ b/packages/rocketchat-livechat/package.js @@ -67,6 +67,7 @@ Package.onUse(function(api) { api.addFiles('client/collections/LivechatInquiry.js', 'client'); api.addFiles('client/collections/livechatOfficeHour.js', 'client'); api.addFiles('client/collections/LivechatVisitor.js', 'client'); + api.addFiles('client/collections/LivechatMessage.js', 'client'); api.addFiles('client/methods/changeLivechatStatus.js', 'client'); @@ -185,6 +186,7 @@ Package.onUse(function(api) { api.addFiles('server/models/LivechatDepartment.js', 'server'); api.addFiles('server/models/LivechatDepartmentAgents.js', 'server'); api.addFiles('server/models/LivechatPageVisited.js', 'server'); + api.addFiles('server/models/LivechatMessage.js', 'server'); api.addFiles('server/models/LivechatTrigger.js', 'server'); api.addFiles('server/models/indexes.js', 'server'); api.addFiles('server/models/LivechatInquiry.js', 'server'); diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js index 4ed0af80f24d..8bac647c2f9b 100644 --- a/packages/rocketchat-livechat/server/lib/Livechat.js +++ b/packages/rocketchat-livechat/server/lib/Livechat.js @@ -311,45 +311,31 @@ RocketChat.Livechat = { }); }, - savePageHistory(token, pageInfo) { + savePageHistory(token, roomId, pageInfo) { if (pageInfo.change === RocketChat.Livechat.historyMonitorType) { - RocketChat.models.Rooms.findByVisitorToken(token).forEach((room) => { + // It's necessary to check the room due to the incMsgCountById method inside RocketChat.models.Rooms.findOneOpenByVisitorToken + const room = RocketChat.models.Rooms.findOneOpenByVisitorToken(token, roomId); + if (!room) { + return false; + } - const users = Meteor.users.find({ - username: { - $in: room.usernames - } - }); + const user = RocketChat.models.Users.findOneById('rocket.cat'); - if (users.count() === 0) { - //return; + const pageTitle = pageInfo.title; + const pageUrl = pageInfo.location.href; + const extraData = { + navigation: { + page: pageInfo, + token } + }; - users.forEach(function(user) { - - RocketChat.Notifications.notifyUser(user._id, 'message', { - _id: Random.id(), - rid: room._id, - ts: new Date, - msg: TAPi18n.__(pageInfo.title, {}, user.language) - }); - - /* - RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', { - _id: Random.id(), - rid: room._id, - ts: new Date, - msg: TAPi18n.__('Visitor Navigation', { - postProcess: 'sprintf', - sprintf: [user.username] - }, currentUser.language) - }) - ;*/ - }); - }); + if (!RocketChat.settings.get('Livechat_Visitor_navigation_as_a_message')) { + extraData._hidden = true; + } - return RocketChat.models.LivechatPageVisited.saveByToken(token, pageInfo); + return RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('livechat_navigation_history', room._id, `${ TAPi18n.__('New_visitor_navigation') }: ${pageTitle} - ${pageUrl}`, user, extraData); } return; diff --git a/packages/rocketchat-livechat/server/methods/pageVisited.js b/packages/rocketchat-livechat/server/methods/pageVisited.js index 25027f03d597..b996bd131bfd 100644 --- a/packages/rocketchat-livechat/server/methods/pageVisited.js +++ b/packages/rocketchat-livechat/server/methods/pageVisited.js @@ -1,5 +1,5 @@ Meteor.methods({ - 'livechat:pageVisited'(token, pageInfo) { - return RocketChat.Livechat.savePageHistory(token, pageInfo); + 'livechat:pageVisited'(token, room, pageInfo) { + return RocketChat.Livechat.savePageHistory(token, room, pageInfo); } }); diff --git a/packages/rocketchat-livechat/server/methods/registerGuest.js b/packages/rocketchat-livechat/server/methods/registerGuest.js index 5cef4e7c19a4..b59eb3461ca0 100644 --- a/packages/rocketchat-livechat/server/methods/registerGuest.js +++ b/packages/rocketchat-livechat/server/methods/registerGuest.js @@ -7,9 +7,6 @@ Meteor.methods({ department }); - // update visited page history to not expire - RocketChat.models.LivechatPageVisited.keepHistoryForToken(token); - return { userId }; diff --git a/packages/rocketchat-livechat/server/methods/sendTranscript.js b/packages/rocketchat-livechat/server/methods/sendTranscript.js index 949642ab232e..a53e271d4380 100644 --- a/packages/rocketchat-livechat/server/methods/sendTranscript.js +++ b/packages/rocketchat-livechat/server/methods/sendTranscript.js @@ -19,7 +19,7 @@ Meteor.methods({ throw new Meteor.Error('error-invalid-room', 'Invalid room'); } - const messages = RocketChat.models.Messages.findVisibleByRoomId(rid, { sort: { 'ts' : 1 }}); + const messages = RocketChat.models.Messages.findVisibleByRoomIdNotContainingTypes(rid, ['livechat_navigation_history'], { sort: { 'ts' : 1 }}); const header = RocketChat.placeholders.replace(RocketChat.settings.get('Email_Header') || ''); const footer = RocketChat.placeholders.replace(RocketChat.settings.get('Email_Footer') || ''); diff --git a/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js b/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js index da77d2c2305c..cfc320803212 100644 --- a/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js +++ b/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js @@ -5,9 +5,6 @@ Meteor.methods({ department }); - // update visited page history to not expire - RocketChat.models.LivechatPageVisited.keepHistoryForToken(token); - return true; } }); diff --git a/packages/rocketchat-livechat/server/models/LivechatMessage.js b/packages/rocketchat-livechat/server/models/LivechatMessage.js new file mode 100644 index 000000000000..caa6e2db2a95 --- /dev/null +++ b/packages/rocketchat-livechat/server/models/LivechatMessage.js @@ -0,0 +1,10 @@ +/** + * Livechat Message model + */ +class LivechatMessage extends RocketChat.models._Base { + constructor() { + super('rocketchat_message'); + } +} + +RocketChat.models.LivechatMessage = new LivechatMessage(); diff --git a/packages/rocketchat-livechat/server/publications/visitorPageVisited.js b/packages/rocketchat-livechat/server/publications/visitorPageVisited.js index 8420694b8138..172cbd9a5689 100644 --- a/packages/rocketchat-livechat/server/publications/visitorPageVisited.js +++ b/packages/rocketchat-livechat/server/publications/visitorPageVisited.js @@ -1,4 +1,5 @@ Meteor.publish('livechat:visitorPageVisited', function({ rid: roomId }) { + if (!this.userId) { return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorPageVisited' })); } @@ -9,8 +10,8 @@ Meteor.publish('livechat:visitorPageVisited', function({ rid: roomId }) { const room = RocketChat.models.Rooms.findOneById(roomId); - if (room && room.v && room.v.token) { - return RocketChat.models.LivechatPageVisited.findByToken(room.v.token); + if (room) { + return RocketChat.models.Messages.findByRoomIdAndType(room._id, 'livechat_navigation_history'); } else { return this.ready(); } diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v108.js new file mode 100644 index 000000000000..02d3bc86d24f --- /dev/null +++ b/server/startup/migrations/v108.js @@ -0,0 +1,47 @@ +import _ from 'underscore'; + +RocketChat.Migrations.add({ + version: 108, + up() { + /* + * Move visitor navigation history to messages + */ + let token = ''; + let roomId; + RocketChat.models.LivechatPageVisited.find({}).forEach((item) => { + + if (token !== item.token) { + const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); + if ((rooms) && (rooms.length > 0)) { + roomId = rooms[0]._id + } else { + roomId = null; + } + token = item.token; + } + if ( roomId ) { + const pageTitle = item.page.title; + const pageUrl = item.page.location.href; + const msg = { + t: "livechat_navigation_history", + rid: roomId, + ts: item.ts, + msg: `${pageTitle} - ${pageUrl}`, + u: { + _id : "rocket.cat", + username : "rocket.cat" + }, + groupable : false, + navigation : { + page: item.page, + token: item.token + } + }; + RocketChat.models.Messages.insert(msg); + } + RocketChat.models.LivechatPageVisited.remove({_id: item._id}); + }); + + return console.log('Moving visitor navigation history to LiveChat messages'); + } +}); From 221c5956fb3557ba273df7a0023399709da448ad Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 12 Mar 2018 10:26:13 -0300 Subject: [PATCH 05/17] Fix Ci build validations. --- .../rocketchat-lib/server/models/Messages.js | 2 +- .../client/views/app/tabbar/visitorNavigation.js | 2 +- .../rocketchat-livechat/server/lib/Livechat.js | 2 +- server/startup/migrations/v108.js | 16 +++++++--------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/rocketchat-lib/server/models/Messages.js b/packages/rocketchat-lib/server/models/Messages.js index 34573e223f7b..5e80d83932c7 100644 --- a/packages/rocketchat-lib/server/models/Messages.js +++ b/packages/rocketchat-lib/server/models/Messages.js @@ -287,7 +287,7 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base { findByRoomIdAndType(roomId, type, options) { const query = { rid: roomId, - t: type, + t: type }; if (options == null) { options = {}; } diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js index 08b4fbd955f1..50c66f402d18 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js @@ -9,7 +9,7 @@ Template.visitorNavigation.helpers({ const room = ChatRoom.findOne({ _id: this.rid }, { fields: { 'v.token': 1 } }); if (room) { - return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history', $or: [{ _shared: { $exists: false }}, { _shared: true }]}, { sort: { ts: -1 } }); + return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history', $or: [{ _shared: { $exists: false }}, { _shared: true }]}, { sort: { ts: -1 } }); } }, diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js index 8bac647c2f9b..142331868dd6 100644 --- a/packages/rocketchat-livechat/server/lib/Livechat.js +++ b/packages/rocketchat-livechat/server/lib/Livechat.js @@ -335,7 +335,7 @@ RocketChat.Livechat = { extraData._hidden = true; } - return RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('livechat_navigation_history', room._id, `${ TAPi18n.__('New_visitor_navigation') }: ${pageTitle} - ${pageUrl}`, user, extraData); + return RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('livechat_navigation_history', room._id, `${ TAPi18n.__('New_visitor_navigation') }: ${ pageTitle } - ${ pageUrl }`, user, extraData); } return; diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v108.js index 02d3bc86d24f..be8dc0ffc059 100644 --- a/server/startup/migrations/v108.js +++ b/server/startup/migrations/v108.js @@ -1,5 +1,3 @@ -import _ from 'underscore'; - RocketChat.Migrations.add({ version: 108, up() { @@ -11,25 +9,25 @@ RocketChat.Migrations.add({ RocketChat.models.LivechatPageVisited.find({}).forEach((item) => { if (token !== item.token) { - const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); + const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); if ((rooms) && (rooms.length > 0)) { - roomId = rooms[0]._id + roomId = rooms[0]._id; } else { roomId = null; } token = item.token; } - if ( roomId ) { + if (roomId) { const pageTitle = item.page.title; const pageUrl = item.page.location.href; const msg = { - t: "livechat_navigation_history", + t: 'livechat_navigation_history', rid: roomId, ts: item.ts, - msg: `${pageTitle} - ${pageUrl}`, + msg: `${ pageTitle } - ${ pageUrl }`, u: { - _id : "rocket.cat", - username : "rocket.cat" + _id : 'rocket.cat', + username : 'rocket.cat' }, groupable : false, navigation : { From bc8c03df652f0539bdcff5a925cef755daf73dec Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Mon, 12 Mar 2018 11:22:51 -0300 Subject: [PATCH 06/17] Fix PR review. --- .eslintrc | 1 + packages/rocketchat-livechat/.app/imports/client/visitor.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 21792799a5c2..4411a205fb2b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -119,6 +119,7 @@ "LivechatDepartmentAgents" : false, "livechatManagerRoutes" : true, "LivechatPageVisited" : false, + "LivechatMessage" : false, "LivechatTrigger" : false, "Logger" : false, "Match" : false, diff --git a/packages/rocketchat-livechat/.app/imports/client/visitor.js b/packages/rocketchat-livechat/.app/imports/client/visitor.js index 568ece8cd3a3..30c127540080 100644 --- a/packages/rocketchat-livechat/.app/imports/client/visitor.js +++ b/packages/rocketchat-livechat/.app/imports/client/visitor.js @@ -1,4 +1,3 @@ -import _ from 'underscore'; /* globals Commands */ const msgStream = new Meteor.Streamer('room-messages'); @@ -68,7 +67,7 @@ export default { msgStream.on(roomId, { token: this.getToken() }, (msg) => { if (msg.t === 'command') { Commands[msg.msg] && Commands[msg.msg](); - } else if (!_.contains(msgTypesNotDisplayed, msg.t)) { + } else if (!msgTypesNotDisplayed.includes(msg.t)) { ChatMessage.upsert({ _id: msg._id }, msg); if (msg.t === 'livechat-close') { From 5b4ec2a2da4f0fbe47453d440972c2526e7130e5 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 14 Mar 2018 11:18:39 -0300 Subject: [PATCH 07/17] Fix filter of the navigation history subscribe. --- .../client/views/app/tabbar/visitorNavigation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js index 50c66f402d18..84703d76d00f 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js @@ -9,7 +9,7 @@ Template.visitorNavigation.helpers({ const room = ChatRoom.findOne({ _id: this.rid }, { fields: { 'v.token': 1 } }); if (room) { - return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history', $or: [{ _shared: { $exists: false }}, { _shared: true }]}, { sort: { ts: -1 } }); + return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history'}, { sort: { ts: -1 } }); } }, From 57d0bf3184de85b2c1cb29e79f36fadf030523ee Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 14 Mar 2018 17:03:58 -0300 Subject: [PATCH 08/17] Fix PR review. --- .eslintrc | 2 +- .../rocketchat-lib/server/models/Messages.js | 28 ++++++++ .../views/app/tabbar/visitorNavigation.js | 3 +- packages/rocketchat-livechat/package.js | 3 +- .../server/lib/Livechat.js | 18 +++-- .../server/methods/registerGuest.js | 3 + .../server/methods/setDepartmentForVisitor.js | 3 + .../server/models/LivechatMessage.js | 10 --- .../server/models/Messages.js | 35 ++++++++++ .../server/publications/visitorPageVisited.js | 21 +++++- server/startup/migrations/v108.js | 69 ++++++++++--------- 11 files changed, 140 insertions(+), 55 deletions(-) delete mode 100644 packages/rocketchat-livechat/server/models/LivechatMessage.js create mode 100644 packages/rocketchat-livechat/server/models/Messages.js diff --git a/.eslintrc b/.eslintrc index 4411a205fb2b..64b39950faf2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -119,7 +119,7 @@ "LivechatDepartmentAgents" : false, "livechatManagerRoutes" : true, "LivechatPageVisited" : false, - "LivechatMessage" : false, + "LivechatMessage" : false, "LivechatTrigger" : false, "Logger" : false, "Match" : false, diff --git a/packages/rocketchat-lib/server/models/Messages.js b/packages/rocketchat-lib/server/models/Messages.js index 5e80d83932c7..e2aed63588cc 100644 --- a/packages/rocketchat-lib/server/models/Messages.js +++ b/packages/rocketchat-lib/server/models/Messages.js @@ -541,6 +541,34 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base { return record; } + createNavigationHistoryWithRoomIdMessageAndUser(roomId, message, user, extraData) { + const type = 'livechat_navigation_history'; + const room = RocketChat.models.Rooms.findOneById(roomId, { fields: { sysMes: 1 }}); + if ((room != null ? room.sysMes : undefined) === false) { + return; + } + const record = { + t: type, + rid: roomId, + ts: new Date, + msg: message, + u: { + _id: user._id, + username: user.username + }, + groupable: false + }; + + if (RocketChat.settings.get('Message_Read_Receipt_Enabled')) { + record.unread = true; + } + + _.extend(record, extraData); + + record._id = this.insertOrUpsert(record); + return record; + } + createUserJoinWithRoomIdAndUser(roomId, user, extraData) { const message = user.username; return this.createWithTypeRoomIdMessageAndUser('uj', roomId, message, user, extraData); diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js index 84703d76d00f..3679a2d1b7ce 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorNavigation.js @@ -1,4 +1,5 @@ import moment from 'moment'; +const visitorNavigationHistory = new Mongo.Collection('visitor_navigation_history'); Template.visitorNavigation.helpers({ loadingNavigation() { @@ -9,7 +10,7 @@ Template.visitorNavigation.helpers({ const room = ChatRoom.findOne({ _id: this.rid }, { fields: { 'v.token': 1 } }); if (room) { - return LivechatMessage.find({rid: room._id, t: 'livechat_navigation_history'}, { sort: { ts: -1 } }); + return visitorNavigationHistory.find({ rid: room._id }, { sort: { ts: -1 } }); } }, diff --git a/packages/rocketchat-livechat/package.js b/packages/rocketchat-livechat/package.js index de106b85ed47..c3d91fcfdf16 100644 --- a/packages/rocketchat-livechat/package.js +++ b/packages/rocketchat-livechat/package.js @@ -67,7 +67,6 @@ Package.onUse(function(api) { api.addFiles('client/collections/LivechatInquiry.js', 'client'); api.addFiles('client/collections/livechatOfficeHour.js', 'client'); api.addFiles('client/collections/LivechatVisitor.js', 'client'); - api.addFiles('client/collections/LivechatMessage.js', 'client'); api.addFiles('client/methods/changeLivechatStatus.js', 'client'); @@ -181,12 +180,12 @@ Package.onUse(function(api) { // models api.addFiles('server/models/Users.js', 'server'); api.addFiles('server/models/Rooms.js', 'server'); + api.addFiles('server/models/Messages.js', 'server'); api.addFiles('server/models/LivechatExternalMessage.js', ['client', 'server']); api.addFiles('server/models/LivechatCustomField.js', 'server'); api.addFiles('server/models/LivechatDepartment.js', 'server'); api.addFiles('server/models/LivechatDepartmentAgents.js', 'server'); api.addFiles('server/models/LivechatPageVisited.js', 'server'); - api.addFiles('server/models/LivechatMessage.js', 'server'); api.addFiles('server/models/LivechatTrigger.js', 'server'); api.addFiles('server/models/indexes.js', 'server'); api.addFiles('server/models/LivechatInquiry.js', 'server'); diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js index 142331868dd6..f98cc2f1a1f7 100644 --- a/packages/rocketchat-livechat/server/lib/Livechat.js +++ b/packages/rocketchat-livechat/server/lib/Livechat.js @@ -105,6 +105,10 @@ RocketChat.Livechat = { throw new Meteor.Error('cannot-access-room'); } + if (newRoom) { + RocketChat.models.Messages.setRoomIdByToken(guest.token, room._id); + } + return { room, newRoom }; }, sendMessage({ guest, message, roomInfo, agent }) { @@ -314,12 +318,6 @@ RocketChat.Livechat = { savePageHistory(token, roomId, pageInfo) { if (pageInfo.change === RocketChat.Livechat.historyMonitorType) { - // It's necessary to check the room due to the incMsgCountById method inside RocketChat.models.Rooms.findOneOpenByVisitorToken - const room = RocketChat.models.Rooms.findOneOpenByVisitorToken(token, roomId); - if (!room) { - return false; - } - const user = RocketChat.models.Users.findOneById('rocket.cat'); const pageTitle = pageInfo.title; @@ -331,11 +329,17 @@ RocketChat.Livechat = { } }; + if (!roomId) { + // keep history of unregistered visitors for 1 month + const keepHistoryMiliseconds = 2592000000; + extraData.expireAt = new Date().getTime() + keepHistoryMiliseconds; + } + if (!RocketChat.settings.get('Livechat_Visitor_navigation_as_a_message')) { extraData._hidden = true; } - return RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('livechat_navigation_history', room._id, `${ TAPi18n.__('New_visitor_navigation') }: ${ pageTitle } - ${ pageUrl }`, user, extraData); + return RocketChat.models.Messages.createNavigationHistoryWithRoomIdMessageAndUser(roomId, `${ TAPi18n.__('New_visitor_navigation') }: ${ pageTitle } - ${ pageUrl }`, user, extraData); } return; diff --git a/packages/rocketchat-livechat/server/methods/registerGuest.js b/packages/rocketchat-livechat/server/methods/registerGuest.js index b59eb3461ca0..0e021d5e6bcb 100644 --- a/packages/rocketchat-livechat/server/methods/registerGuest.js +++ b/packages/rocketchat-livechat/server/methods/registerGuest.js @@ -7,6 +7,9 @@ Meteor.methods({ department }); + // update visited page history to not expire + RocketChat.models.Messages.keepHistoryForToken(token); + return { userId }; diff --git a/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js b/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js index cfc320803212..0c4f40598477 100644 --- a/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js +++ b/packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js @@ -5,6 +5,9 @@ Meteor.methods({ department }); + // update visited page history to not expire + RocketChat.models.Messages.keepHistoryForToken(token); + return true; } }); diff --git a/packages/rocketchat-livechat/server/models/LivechatMessage.js b/packages/rocketchat-livechat/server/models/LivechatMessage.js deleted file mode 100644 index caa6e2db2a95..000000000000 --- a/packages/rocketchat-livechat/server/models/LivechatMessage.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Livechat Message model - */ -class LivechatMessage extends RocketChat.models._Base { - constructor() { - super('rocketchat_message'); - } -} - -RocketChat.models.LivechatMessage = new LivechatMessage(); diff --git a/packages/rocketchat-livechat/server/models/Messages.js b/packages/rocketchat-livechat/server/models/Messages.js new file mode 100644 index 000000000000..9ff9ecf2525e --- /dev/null +++ b/packages/rocketchat-livechat/server/models/Messages.js @@ -0,0 +1,35 @@ +RocketChat.models.Messages.keepHistoryForToken = function(token) { + return this.update( + { + 'navigation.token': token, + expireAt: { + $exists: true + } + }, + { + $unset: { + expireAt: 1 + } + }, + { + multi: true + } + ); +}; + +RocketChat.models.Messages.setRoomIdByToken = function(token, roomId) { + return this.update( + { + 'navigation.token': token, + rid: null + }, + { + $set: { + rid: roomId + } + }, + { + multi: true + } + ); +}; diff --git a/packages/rocketchat-livechat/server/publications/visitorPageVisited.js b/packages/rocketchat-livechat/server/publications/visitorPageVisited.js index 172cbd9a5689..72d7b42df3b1 100644 --- a/packages/rocketchat-livechat/server/publications/visitorPageVisited.js +++ b/packages/rocketchat-livechat/server/publications/visitorPageVisited.js @@ -8,11 +8,28 @@ Meteor.publish('livechat:visitorPageVisited', function({ rid: roomId }) { return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorPageVisited' })); } + const self = this; const room = RocketChat.models.Rooms.findOneById(roomId); if (room) { - return RocketChat.models.Messages.findByRoomIdAndType(room._id, 'livechat_navigation_history'); + const handle = RocketChat.models.Messages.findByRoomIdAndType(room._id, 'livechat_navigation_history').observeChanges({ + added(id, fields) { + self.added('visitor_navigation_history', id, fields); + }, + changed(id, fields) { + self.changed('visitor_navigation_history', id, fields); + }, + removed(id) { + self.removed('visitor_navigation_history', id); + } + }); + + self.ready(); + + self.onStop(function() { + handle.stop(); + }); } else { - return this.ready(); + self.ready(); } }); diff --git a/server/startup/migrations/v108.js b/server/startup/migrations/v108.js index be8dc0ffc059..671101702a97 100644 --- a/server/startup/migrations/v108.js +++ b/server/startup/migrations/v108.js @@ -6,40 +6,45 @@ RocketChat.Migrations.add({ */ let token = ''; let roomId; - RocketChat.models.LivechatPageVisited.find({}).forEach((item) => { - if (token !== item.token) { - const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); - if ((rooms) && (rooms.length > 0)) { - roomId = rooms[0]._id; - } else { - roomId = null; - } - token = item.token; - } - if (roomId) { - const pageTitle = item.page.title; - const pageUrl = item.page.location.href; - const msg = { - t: 'livechat_navigation_history', - rid: roomId, - ts: item.ts, - msg: `${ pageTitle } - ${ pageUrl }`, - u: { - _id : 'rocket.cat', - username : 'rocket.cat' - }, - groupable : false, - navigation : { - page: item.page, - token: item.token + console.log('Migrating livechat visitors navigation history to livechat messages ...'); + + Meteor.setTimeout(() => { + RocketChat.models.LivechatPageVisited.find({}).forEach((item) => { + + if (token !== item.token) { + const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); + if ((rooms) && (rooms.length > 0)) { + roomId = rooms[0]._id; + } else { + roomId = null; } - }; - RocketChat.models.Messages.insert(msg); - } - RocketChat.models.LivechatPageVisited.remove({_id: item._id}); - }); + token = item.token; + } + if (roomId) { + const pageTitle = item.page.title; + const pageUrl = item.page.location.href; + const msg = { + t: 'livechat_navigation_history', + rid: roomId, + ts: item.ts, + msg: `${ pageTitle } - ${ pageUrl }`, + u: { + _id : 'rocket.cat', + username : 'rocket.cat' + }, + groupable : false, + navigation : { + page: item.page, + token: item.token + } + }; + RocketChat.models.Messages.insert(msg); + } + RocketChat.models.LivechatPageVisited.remove({_id: item._id}); + }); - return console.log('Moving visitor navigation history to LiveChat messages'); + console.log('Livechat visitors navigation history migration finished.'); + }, 1000); } }); From a25f9ea201de7c85a573680728e670d32ddacb82 Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Tue, 29 May 2018 18:32:59 -0300 Subject: [PATCH 09/17] New feature added to send messages related to Livechat visitor navigation in CRM integrations. --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 ++ packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 4 +++- packages/rocketchat-livechat/config.js | 9 ++++++++ .../server/hooks/sendToCRM.js | 21 +++++++++++++++---- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 2235e76272d6..46ade1415c7c 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -826,6 +826,7 @@ "False": "False", "Favorite_Rooms": "Enable Favorite Rooms", "Favorites": "Favorites", + "Feature_Depends_on_Livechat_Visitor_navigation_as_a_message_to_be_enabled": "This feature depends on \"Send Visitor Navigation History as a Message\" to be enabled.", "Features_Enabled": "Features Enabled", "Field": "Field", "Field_removed": "Field removed", @@ -1463,6 +1464,7 @@ "Monday": "Monday", "Monitor_history_for_changes_on": "Monitor History for Changes on", "Send_Visitor_navigation_history_as_a_message": "Send Visitor Navigation History as a Message", + "Send_visitor_navigation_history_on_request": "Send Visitor Navigation History on Request", "More_channels": "More channels", "More_direct_messages": "More direct messages", "More_groups": "More private groups", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 58a0527a4c87..1802d9c1dfcb 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -794,6 +794,7 @@ "False": "Não", "Favorite_Rooms": "Ativar salas favoritas", "Favorites": "Favoritos", + "Feature_Depends_on_Livechat_Visitor_navigation_as_a_message_to_be_enabled": "Esta Funcionalidade depende que \"Enviar histórico de navegação do visitante como mensagem\" esteja habilitada.", "Features_Enabled": "Funcionalidades habilitadas", "Field": "Campo", "Field_removed": "Campo removido", @@ -1416,7 +1417,6 @@ "Mobile_Notifications_Default_Alert": "Alertas Padrão de Notificações Móveis", "Monday": "Segunda-feira", "Monitor_history_for_changes_on": "Monitorar mudanças de histórico para", - "Send_Visitor_navigation_history_as_a_message": "Enviar histórico de navegação do visitante como mensagem", "More_channels": "Mais canais", "More_direct_messages": "Mais mensagens diretas", "More_groups": "Mais grupos privados", @@ -1820,6 +1820,8 @@ "Send_request_on_visitor_message": "Enviar requisição para mensagens do Visitante", "Send_request_on_agent_message": "Enviar requisição para mensagens do Agente", "Send_Test": "Enviar teste", + "Send_Visitor_navigation_history_as_a_message": "Enviar histórico de navegação do visitante como mensagem", + "Send_visitor_navigation_history_on_request": "Enviar histórico de navegação do visitante na requisição", "Send_welcome_email": "Enviar e-mail de boas-vindas", "Send_your_JSON_payloads_to_this_URL": "Envie seu payload JSON para esta URL.", "Sending": "Enviando ...", diff --git a/packages/rocketchat-livechat/config.js b/packages/rocketchat-livechat/config.js index ca060461ec88..a5c50af59ff7 100644 --- a/packages/rocketchat-livechat/config.js +++ b/packages/rocketchat-livechat/config.js @@ -181,6 +181,15 @@ Meteor.startup(function() { i18nLabel: 'Send_request_on_agent_message' }); + RocketChat.settings.add('Send_visitor_navigation_history_livechat_webhook_request', false, { + type: 'boolean', + group: 'Livechat', + section: 'CRM_Integration', + i18nLabel: 'Send_visitor_navigation_history_on_request', + i18nDescription: 'Feature_Depends_on_Livechat_Visitor_navigation_as_a_message_to_be_enabled', + enableQuery: { _id: 'Livechat_Visitor_navigation_as_a_message', value: true } + }); + RocketChat.settings.add('Livechat_webhook_on_capture', false, { type: 'boolean', group: 'Livechat', diff --git a/packages/rocketchat-livechat/server/hooks/sendToCRM.js b/packages/rocketchat-livechat/server/hooks/sendToCRM.js index 46e48dcc70fe..8ef065c7f270 100644 --- a/packages/rocketchat-livechat/server/hooks/sendToCRM.js +++ b/packages/rocketchat-livechat/server/hooks/sendToCRM.js @@ -1,3 +1,11 @@ +const msgNavType = 'livechat_navigation_history'; + +const sendMessageType = (msgType) => { + const sendNavHistory = RocketChat.settings.get('Livechat_Visitor_navigation_as_a_message') && RocketChat.settings.get('Send_visitor_navigation_history_livechat_webhook_request'); + + return sendNavHistory && msgType == msgNavType; +} + function sendToCRM(type, room, includeMessages = true) { const postData = RocketChat.Livechat.getLivechatRoomGuestInfo(room); @@ -14,7 +22,7 @@ function sendToCRM(type, room, includeMessages = true) { if (messages) { messages.forEach((message) => { - if (message.t) { + if ((message.t) && (!(sendMessageType(message.t)))) { return; } const msg = { @@ -28,6 +36,11 @@ function sendToCRM(type, room, includeMessages = true) { if (message.u.username !== postData.visitor.username) { msg.agentId = message.u._id; } + + if (message.t == msgNavType) { + msg.navigation = message.navigation + } + postData.messages.push(msg); }); } @@ -59,7 +72,7 @@ RocketChat.callbacks.add('livechat.saveInfo', (room) => { }, RocketChat.callbacks.priority.MEDIUM, 'livechat-send-crm-save-info'); RocketChat.callbacks.add('afterSaveMessage', function(message, room) { - // only call webhook if it is a livechat room + // only call webhook if it is a livechat room if (room.t !== 'l' || room.v == null || room.v.token == null) { return message; } @@ -73,9 +86,9 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { } else if (!RocketChat.settings.get('Livechat_webhook_on_agent_message')) { return message; } - // if the message has a type means it is a special message (like the closing comment), so skips - if (message.t) { + // unless the settings that handle with visitor navigation history are enabled + if ((message.t) && (!(sendMessageType(message.t)))) { return message; } From 632baf16d6657febc6a97965d0daa6a10ed8d9cf Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Tue, 29 May 2018 18:45:47 -0300 Subject: [PATCH 10/17] Fix codacy-bot review issues. --- packages/rocketchat-livechat/server/hooks/sendToCRM.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/rocketchat-livechat/server/hooks/sendToCRM.js b/packages/rocketchat-livechat/server/hooks/sendToCRM.js index 8ef065c7f270..92c0c56e89a9 100644 --- a/packages/rocketchat-livechat/server/hooks/sendToCRM.js +++ b/packages/rocketchat-livechat/server/hooks/sendToCRM.js @@ -3,8 +3,8 @@ const msgNavType = 'livechat_navigation_history'; const sendMessageType = (msgType) => { const sendNavHistory = RocketChat.settings.get('Livechat_Visitor_navigation_as_a_message') && RocketChat.settings.get('Send_visitor_navigation_history_livechat_webhook_request'); - return sendNavHistory && msgType == msgNavType; -} + return sendNavHistory && msgType === msgNavType; +}; function sendToCRM(type, room, includeMessages = true) { const postData = RocketChat.Livechat.getLivechatRoomGuestInfo(room); @@ -37,8 +37,8 @@ function sendToCRM(type, room, includeMessages = true) { msg.agentId = message.u._id; } - if (message.t == msgNavType) { - msg.navigation = message.navigation + if (message.t === msgNavType) { + msg.navigation = message.navigation; } postData.messages.push(msg); @@ -72,7 +72,7 @@ RocketChat.callbacks.add('livechat.saveInfo', (room) => { }, RocketChat.callbacks.priority.MEDIUM, 'livechat-send-crm-save-info'); RocketChat.callbacks.add('afterSaveMessage', function(message, room) { - // only call webhook if it is a livechat room + // only call webhook if it is a livechat room if (room.t !== 'l' || room.v == null || room.v.token == null) { return message; } From d3145653ae243d4c840cb6c2f1ad8f338c258f3d Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 01:38:11 -0300 Subject: [PATCH 11/17] Fix coding styling --- .../server/hooks/sendToCRM.js | 4 +- .../server/models/Messages.js | 50 ++++++++----------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/packages/rocketchat-livechat/server/hooks/sendToCRM.js b/packages/rocketchat-livechat/server/hooks/sendToCRM.js index 92c0c56e89a9..fe4f68218063 100644 --- a/packages/rocketchat-livechat/server/hooks/sendToCRM.js +++ b/packages/rocketchat-livechat/server/hooks/sendToCRM.js @@ -22,7 +22,7 @@ function sendToCRM(type, room, includeMessages = true) { if (messages) { messages.forEach((message) => { - if ((message.t) && (!(sendMessageType(message.t)))) { + if (message.t && !sendMessageType(message.t)) { return; } const msg = { @@ -88,7 +88,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { } // if the message has a type means it is a special message (like the closing comment), so skips // unless the settings that handle with visitor navigation history are enabled - if ((message.t) && (!(sendMessageType(message.t)))) { + if (message.t && !sendMessageType(message.t)) { return message; } diff --git a/packages/rocketchat-livechat/server/models/Messages.js b/packages/rocketchat-livechat/server/models/Messages.js index 9ff9ecf2525e..da2046be7426 100644 --- a/packages/rocketchat-livechat/server/models/Messages.js +++ b/packages/rocketchat-livechat/server/models/Messages.js @@ -1,35 +1,27 @@ RocketChat.models.Messages.keepHistoryForToken = function(token) { - return this.update( - { - 'navigation.token': token, - expireAt: { - $exists: true - } - }, - { - $unset: { - expireAt: 1 - } - }, - { - multi: true + return this.update({ + 'navigation.token': token, + expireAt: { + $exists: true } - ); + }, { + $unset: { + expireAt: 1 + } + }, { + multi: true + }); }; -RocketChat.models.Messages.setRoomIdByToken = function(token, roomId) { - return this.update( - { - 'navigation.token': token, - rid: null - }, - { - $set: { - rid: roomId - } - }, - { - multi: true +RocketChat.models.Messages.setRoomIdByToken = function(token, rid) { + return this.update({ + 'navigation.token': token, + rid: null + }, { + $set: { + rid } - ); + }, { + multi: true + }); }; From 2cc736b7df2433da954dfff1b66ee867da01d801 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 01:38:36 -0300 Subject: [PATCH 12/17] Do not return message on pageVisited method --- packages/rocketchat-livechat/server/methods/pageVisited.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-livechat/server/methods/pageVisited.js b/packages/rocketchat-livechat/server/methods/pageVisited.js index b996bd131bfd..0097ac4aab5b 100644 --- a/packages/rocketchat-livechat/server/methods/pageVisited.js +++ b/packages/rocketchat-livechat/server/methods/pageVisited.js @@ -1,5 +1,5 @@ Meteor.methods({ 'livechat:pageVisited'(token, room, pageInfo) { - return RocketChat.Livechat.savePageHistory(token, room, pageInfo); + RocketChat.Livechat.savePageHistory(token, room, pageInfo); } }); From bf9081797591066897bb001a0d7b6b5d5fa747ca Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 01:39:05 -0300 Subject: [PATCH 13/17] Better styling for navigation history messages --- .../rocketchat-theme/client/imports/general/base_old.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/rocketchat-theme/client/imports/general/base_old.css b/packages/rocketchat-theme/client/imports/general/base_old.css index 7005727ff8a3..78602ce7ecab 100644 --- a/packages/rocketchat-theme/client/imports/general/base_old.css +++ b/packages/rocketchat-theme/client/imports/general/base_old.css @@ -3271,6 +3271,12 @@ font-weight: 400; } + + &.livechat_navigation_history { + & .thumb, & .user, & .info { + display: none; + } + } } .rc-old .image-labels { From b2535ea390fc8dc5e8ea9b6830547524e7db8bbe Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 01:39:25 -0300 Subject: [PATCH 14/17] Improved livechat history migration to run faster --- server/startup/migrations/v123.js | 117 ++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 39 deletions(-) diff --git a/server/startup/migrations/v123.js b/server/startup/migrations/v123.js index 340a18749e33..e1e0b7b4fe1e 100644 --- a/server/startup/migrations/v123.js +++ b/server/startup/migrations/v123.js @@ -1,48 +1,87 @@ +let pageVisitedCollection; +let messageCollection; +let roomCollection; + +const roomIdByToken = {}; + +const batchSize = 5000; + +async function migrateHistory(total, current) { + console.log(`Livechat history migration ${ current }/${ total }`); + + const items = await pageVisitedCollection.find({}).limit(batchSize).toArray(); + + const tokens = items.filter((item) => item.token && !roomIdByToken[item.token]).map((item) => item.token); + const rooms = await roomCollection.find({ + 'v.token': { + $in: tokens + } + }, { + fields: { + 'v.token': 1 + } + }).toArray(); + + rooms.forEach((room) => { + roomIdByToken[room.v.token] = room._id; + }); + + const actions = items.reduce((result, item) => { + const msg = { + t: 'livechat_navigation_history', + rid: roomIdByToken[item.token] || null, // prevent from being `undefined` + ts: item.ts, + msg: `${ item.page.title } - ${ item.page.location.href }`, + u: { + _id : 'rocket.cat', + username : 'rocket.cat' + }, + groupable : false, + navigation : { + page: item.page, + token: item.token + } + }; + if (!roomIdByToken[item.token] && item.expireAt) { + msg.expireAt = item.expireAt; + } + result.insert.push(msg); + result.remove.push(item._id); + + return result; + }, { insert: [], remove: [] }); + + const batch = Promise.all([ + messageCollection.insertMany(actions.insert), + pageVisitedCollection.removeMany({ _id: { $in: actions.remove } }) + ]); + if (actions.remove.length === batchSize) { + await batch; + return migrateHistory(total, current + batchSize); + } + + return batch; +} + + RocketChat.Migrations.add({ version: 123, up() { + pageVisitedCollection = RocketChat.models.LivechatPageVisited.model.rawCollection(); + messageCollection = RocketChat.models.Messages.model.rawCollection(); + roomCollection = RocketChat.models.Rooms.model.rawCollection(); + /* * Move visitor navigation history to messages */ - let token = ''; - let roomId; - - console.log('Migrating livechat visitors navigation history to livechat messages ...'); - - Meteor.setTimeout(() => { - RocketChat.models.LivechatPageVisited.find({}).forEach((item) => { - - if (token !== item.token) { - const rooms = RocketChat.models.Rooms.findByVisitorToken(item.token).fetch(); - if ((rooms) && (rooms.length > 0)) { - roomId = rooms[0]._id; - } else { - roomId = null; - } - token = item.token; - } - if (roomId) { - const pageTitle = item.page.title; - const pageUrl = item.page.location.href; - const msg = { - t: 'livechat_navigation_history', - rid: roomId, - ts: item.ts, - msg: `${ pageTitle } - ${ pageUrl }`, - u: { - _id : 'rocket.cat', - username : 'rocket.cat' - }, - groupable : false, - navigation : { - page: item.page, - token: item.token - } - }; - RocketChat.models.Messages.insert(msg); - } - RocketChat.models.LivechatPageVisited.remove({_id: item._id}); - }); + Meteor.setTimeout(async() => { + const pages = pageVisitedCollection.find({}); + const total = await pages.count(); + await pages.close(); + + console.log('Migrating livechat visitors navigation history to livechat messages. This might take a long time ...'); + + await migrateHistory(total, 0); console.log('Livechat visitors navigation history migration finished.'); }, 1000); From cb2274d4e4ca954217529cc916554a61b56ac0d6 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 13:52:00 -0300 Subject: [PATCH 15/17] Disable showing livechat navigation history as message by default --- packages/rocketchat-livechat/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-livechat/config.js b/packages/rocketchat-livechat/config.js index 9f996d77bda6..236da5c59013 100644 --- a/packages/rocketchat-livechat/config.js +++ b/packages/rocketchat-livechat/config.js @@ -245,7 +245,7 @@ Meteor.startup(function() { ] }); - RocketChat.settings.add('Livechat_Visitor_navigation_as_a_message', true, { + RocketChat.settings.add('Livechat_Visitor_navigation_as_a_message', false, { type: 'boolean', group: 'Livechat', public: true, From c086d6c6493799d3bd0e305b53cec16a2c96b019 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 16:00:18 -0300 Subject: [PATCH 16/17] Better visitor navigation translation --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 4 ++-- packages/rocketchat-livechat/messageTypes.js | 11 ++++++++++- packages/rocketchat-livechat/server/lib/Livechat.js | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 56b7a957d5cd..4c04064432c9 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1508,7 +1508,7 @@ "New_Trigger": "New Trigger", "New_version_available_(s)": "New version available (%s)", "New_videocall_request": "New Video Call Request", - "New_visitor_navigation": "New Visitor Navigation", + "New_visitor_navigation": "New Navigation: __history__", "No_available_agents_to_transfer": "No available agents to transfer", "No_channel_with_name_%s_was_found": "No channel with name \"%s\" was found!", "No_channels_yet": "You aren't part of any channel yet", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 1802d9c1dfcb..ed5812e037ac 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -1459,7 +1459,7 @@ "New_Trigger": "Novo Gatilho", "New_version_available_(s)": "Nova versão disponível (% s)", "New_videocall_request": "Nova requisição de chamada de vídeo", - "New_visitor_navigation": "Nova Navegação do visitante", + "New_visitor_navigation": "Nova Navegação: __history__", "No_available_agents_to_transfer": "Nenhum agente disponível para transferir", "No_channel_with_name_%s_was_found": "Nenhum canal com nome \"%s\" foi encontrado!", "No_channels_yet": "Você não faz parte de nenhum canal ainda.", @@ -2352,4 +2352,4 @@ "your_message_optional": "sua mensagem (opcional)", "Your_password_is_wrong": "Sua senha está errada!", "Your_push_was_sent_to_s_devices": "Sua notificação foi enviada para %s dispositivos" -} \ No newline at end of file +} diff --git a/packages/rocketchat-livechat/messageTypes.js b/packages/rocketchat-livechat/messageTypes.js index 606eb5f8ce16..631ecc47166f 100644 --- a/packages/rocketchat-livechat/messageTypes.js +++ b/packages/rocketchat-livechat/messageTypes.js @@ -1,6 +1,15 @@ RocketChat.MessageTypes.registerType({ id: 'livechat_navigation_history', - system: true + system: true, + message: 'New_visitor_navigation', + data(message) { + if (!message.navigation || !message.navigation.page) { + return; + } + return { + history: `${ (message.navigation.page.title ? `${ message.navigation.page.title } - ` : '') + message.navigation.page.location.href }` + }; + } }); RocketChat.MessageTypes.registerType({ diff --git a/packages/rocketchat-livechat/server/lib/Livechat.js b/packages/rocketchat-livechat/server/lib/Livechat.js index 4d0006b6f362..c8e19915cb74 100644 --- a/packages/rocketchat-livechat/server/lib/Livechat.js +++ b/packages/rocketchat-livechat/server/lib/Livechat.js @@ -343,7 +343,7 @@ RocketChat.Livechat = { extraData._hidden = true; } - return RocketChat.models.Messages.createNavigationHistoryWithRoomIdMessageAndUser(roomId, `${ TAPi18n.__('New_visitor_navigation') }: ${ pageTitle } - ${ pageUrl }`, user, extraData); + return RocketChat.models.Messages.createNavigationHistoryWithRoomIdMessageAndUser(roomId, `${ pageTitle } - ${ pageUrl }`, user, extraData); } return; From b350a0b54d4970fef5d000308cd60ac587f7ad54 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 5 Jun 2018 16:08:30 -0300 Subject: [PATCH 17/17] Remove unnecessary files --- .eslintrc | 1 - .../rocketchat-livechat/client/collections/LivechatMessage.js | 1 - 2 files changed, 2 deletions(-) delete mode 100644 packages/rocketchat-livechat/client/collections/LivechatMessage.js diff --git a/.eslintrc b/.eslintrc index db97f8b02d16..32ba25020b8a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -119,7 +119,6 @@ "LivechatDepartmentAgents" : false, "livechatManagerRoutes" : true, "LivechatPageVisited" : false, - "LivechatMessage" : false, "LivechatTrigger" : false, "Logger" : false, "Match" : false, diff --git a/packages/rocketchat-livechat/client/collections/LivechatMessage.js b/packages/rocketchat-livechat/client/collections/LivechatMessage.js deleted file mode 100644 index 456375d8575d..000000000000 --- a/packages/rocketchat-livechat/client/collections/LivechatMessage.js +++ /dev/null @@ -1 +0,0 @@ -this.LivechatMessage = new Mongo.Collection('rocketchat_message');