Skip to content

Commit

Permalink
Merge pull request #4389 from RocketChat/livechat-fixes-0-40
Browse files Browse the repository at this point in the history
Livechat fixes for 0.40
  • Loading branch information
engelgabriel authored Sep 21, 2016
2 parents 73ad7c7 + c12b58d commit ed587f8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import UAParser from 'ua-parser-js';

Template.visitorInfo.helpers({
user() {
const user = Template.instance().user.get();
Expand Down
8 changes: 0 additions & 8 deletions packages/rocketchat-livechat/lib/ua-parser.js

This file was deleted.

7 changes: 4 additions & 3 deletions packages/rocketchat-livechat/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Package.registerBuildPlugin({
}
});

Npm.depends({
'ua-parser-js': '0.7.10'
});

Package.onUse(function(api) {
api.use(['webapp', 'autoupdate'], 'server');
api.use('ecmascript');
Expand Down Expand Up @@ -43,9 +47,6 @@ Package.onUse(function(api) {
api.addFiles('client/ui.js', 'client');
api.addFiles('client/route.js', 'client');

// generic libs
api.addFiles('lib/ua-parser.js');

// add stylesheets to theme compiler
api.addAssets('client/stylesheets/livechat.less', 'server');
api.addFiles('client/stylesheets/load.js', 'server');
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* globals HTTP */
import UAParser from 'ua-parser-js';

RocketChat.Livechat = {
historyMonitorType: 'url',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class LivechatDepartmentAgents extends RocketChat.models._Base {
var agent = findAndModify(query, sort, update);
if (agent) {
return {
agentId: agent.agentId,
username: agent.username
agentId: agent.value.agentId,
username: agent.value.username
};
} else {
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-livechat/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RocketChat.models.Rooms.getNextLivechatRoomCode = function() {

const livechatCount = findAndModify(query, null, update);

return livechatCount.value;
return livechatCount.value.value;
};

RocketChat.models.Rooms.findOpenByVisitorToken = function(visitorToken, options) {
Expand Down
6 changes: 3 additions & 3 deletions packages/rocketchat-livechat/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ RocketChat.models.Users.getNextAgent = function() {
var user = findAndModify(query, sort, update);
if (user) {
return {
agentId: user._id,
username: user.username
agentId: user.value._id,
username: user.value.username
};
} else {
return null;
Expand Down Expand Up @@ -203,5 +203,5 @@ RocketChat.models.Users.getNextVisitorUsername = function() {

const livechatCount = findAndModify(query, null, update);

return 'guest-' + (livechatCount.value + 1);
return 'guest-' + (livechatCount.value.value + 1);
};

0 comments on commit ed587f8

Please sign in to comment.