Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/rocketchat-livechat/.app/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ mizzao:timesync
[email protected]
[email protected]
tap:i18n
smoral:sweetalert
[email protected]
[email protected]
[email protected]
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-livechat/.app/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ [email protected]
[email protected]
[email protected]
[email protected]
smoral:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-livechat/.app/client/lib/chatMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ this.ChatMessages = class ChatMessages {
}

visitor.setId(result.userId);
visitor.setData(result.visitor);

sendMessage();
});
} else {
Expand Down
52 changes: 24 additions & 28 deletions packages/rocketchat-livechat/.app/client/lib/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals LivechatVideoCall, Livechat, swal */
/* globals LivechatVideoCall, Livechat */
import swal from 'sweetalert2';
import visitor from '../../imports/client/visitor';

// Functions to call on messages of type 'command'
Expand All @@ -22,38 +23,33 @@ this.Commands = {
swal({
title: t('Chat_ended'),
text: transcriptMessage,
type: 'input',
input: 'email',
inputValue: email,
inputPlaceholder: t('Type_your_email'),
showCancelButton: true,
cancelButtonText: t('no'),
confirmButtonText: t('yes'),
closeOnCancel: true,
closeOnConfirm: false
}, (response) => {
if ((typeof response === 'boolean') && !response) {
confirmButtonText: t('yes')
}).then((result) => {
if ((typeof result.value === 'boolean') && !result.value) {
return true;
} else {
if (!response) {
swal.showInputError(t('please enter your email'));
return false;
}
if (response.trim() === '') {
swal.showInputError(t('please enter your email'));
return false;
} else {
Meteor.call('livechat:sendTranscript', visitor.getToken(), visitor.getRoom(), response, (err) => {
if (err) {
console.error(err);
}
swal({
title: t('transcript_sent'),
type: 'success',
timer: 1000,
showConfirmButton: false
});
});
}
}

if (!result.value || result.value.trim() === '') {
swal.showValidationError(t('please enter your email'));
return false;
}

Meteor.call('livechat:sendTranscript', visitor.getToken(), visitor.getRoom(), result.value, (err) => {
if (err) {
console.error(err);
}
swal({
title: t('transcript_sent'),
type: 'success',
timer: 1000,
showConfirmButton: false
});
});
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,13 @@ input:focus {
position: fixed;
height: 100%;
width: 100%;
z-index: 9990;
z-index: 990;
top: 0;
left: 0;
}

.wrapper {
z-index: 9999;
z-index: 999;
background: white;
position: fixed;
height: 80%;
Expand Down
21 changes: 9 additions & 12 deletions packages/rocketchat-livechat/.app/client/views/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals Department, Livechat, swal */
/* globals Department, Livechat */
import swal from 'sweetalert2';
import visitor from '../../imports/client/visitor';

Template.options.helpers({
Expand All @@ -23,19 +24,15 @@ Template.options.events({
confirmButtonColor: '#DD6B55',
confirmButtonText: t('Yes'),
cancelButtonText: t('No'),
closeOnConfirm: true,
html: false
}, () => {
Meteor.call('livechat:closeByVisitor', { roomId: visitor.getRoom(), token: visitor.getToken() }, (error) => {
if (error) {
return console.log('Error ->', error);
}
swal({
title: t('Chat_ended'),
type: 'success',
timer: 2000
}).then((result) => {
if (result.value) {
Meteor.call('livechat:closeByVisitor', { roomId: visitor.getRoom(), token: visitor.getToken() }, (error) => {
if (error) {
return console.log('Error ->', error);
}
});
});
}
});
},
'click .switch-department'() {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-livechat/.app/client/views/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Template.register.events({
}
parentCall('callback', ['pre-chat-form-submit', _.omit(guest, 'token')]);
visitor.setId(result.userId);
visitor.setData(result.visitor);
start();
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-livechat/.app/client/views/survey.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals swal */
/* globals */
import swal from 'sweetalert2';
import visitor from '../../imports/client/visitor';

Template.survey.events({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals Department, Livechat, swal */
/* globals Department, Livechat */
import swal from 'sweetalert2';
import visitor from '../../imports/client/visitor';

Template.switchDepartment.helpers({
Expand Down Expand Up @@ -42,9 +43,12 @@ Template.switchDepartment.events({
confirmButtonColor: '#DD6B55',
confirmButtonText: t('Yes'),
cancelButtonText: t('No'),
closeOnConfirm: true,
html: false
}, () => {
}).then((result) => {
if (!result.value) {
return;
}

Meteor.call('livechat:closeByVisitor', { roomId: visitor.getRoom(), token: visitor.getToken() }, (error) => {
if (error) {
return console.log('Error ->', error);
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-livechat/.app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"core-js": "^2.5.7",
"jquery": "^3.3.1",
"moment": "^2.22.2",
"sweetalert2": "^7.20.7",
"toastr": "^2.1.4",
"underscore": "^1.9.1",
"underscore.string": "^3.3.4"
Expand Down
13 changes: 12 additions & 1 deletion packages/rocketchat-livechat/server/methods/registerGuest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import LivechatVisitors from '../models/LivechatVisitors';

Meteor.methods({
'livechat:registerGuest'({ token, name, email, department } = {}) {
const userId = RocketChat.Livechat.registerGuest.call(this, {
Expand All @@ -10,8 +12,17 @@ Meteor.methods({
// update visited page history to not expire
RocketChat.models.Messages.keepHistoryForToken(token);

const visitor = LivechatVisitors.getVisitorByToken(token, {
fields: {
name: 1,
username: 1,
visitorEmails: 1
}
});

return {
userId
userId,
visitor
};
}
});