Skip to content

Commit

Permalink
[NEW]Set up livechat connections created from new client (#14236)
Browse files Browse the repository at this point in the history
* Adds a new method to set up livechat connections.

* Store livechatToken into connection.
  • Loading branch information
renatobecker committed Apr 24, 2019
1 parent 2ce3eea commit a0672ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import './methods/startVideoCall';
import './methods/startFileUploadRoom';
import './methods/transfer';
import './methods/webhookTest';
import './methods/setUpConnection';
import './methods/takeInquiry';
import './methods/returnAsInquiry';
import './methods/saveOfficeHours';
Expand Down
21 changes: 21 additions & 0 deletions app/livechat/server/methods/setUpConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Livechat } from '../lib/Livechat';

Meteor.methods({
'livechat:setUpConnection'(data) {

check(data, {
token: String,
});

const { token } = data;

if (!this.connection.livechatToken) {
this.connection.livechatToken = token;
this.connection.onClose(() => {
Livechat.notifyGuestStatusChanged(token, 'offline');
});
}
},
});

0 comments on commit a0672ae

Please sign in to comment.