Skip to content
Snippets Groups Projects
Commit 7b1c4f04 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

Merge pull request #1586 from RocketChat/livechat-fix-visitor-losing-session

Fix livechat room issues
parents 6ff62d1e 9e8b3a55
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ Template.room.events
Template.room.onCreated ->
self = @
self.autorun ->
self.subscribe 'visitorRoom', visitor.getToken(), ->
self.subscribe 'livechat:visitorRoom', visitor.getToken(), ->
room = ChatRoom.findOne()
if room?
visitor.setRoom room._id
......
......@@ -53,6 +53,7 @@ Package.onUse(function(api) {
// publications
api.addFiles('server/publications/livechatAgents.js', 'server');
api.addFiles('server/publications/livechatManagers.js', 'server');
api.addFiles('server/publications/visitorRoom.js', 'server');
// livechat app
api.addAssets('rocket-livechat.js', 'client');
......
Meteor.publish('livechat:visitorRoom', function(visitorToken) {
console.log('[publish] livechat:visitorRoom -> '.green, 'arguments:', arguments);
return RocketChat.models.Rooms.findByVisitorToken(visitorToken, {
fields: {
name: 1,
t: 1,
cl: 1,
u: 1,
usernames: 1,
v: 1
}
});
});
......@@ -94,10 +94,10 @@ RocketChat.Notifications.onUser 'message', (msg) ->
query =
t: type
if type in ['c', 'p']
query.name = name
else if type is 'd'
if type is 'd'
query.usernames = $all: [Meteor.user()?.username, name]
else
query.name = name
room = ChatRoom.findOne query, { reactive: false }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment