Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Livechat visitor not being prompted for transcript when himself is closing the chat #10767

Merged
merged 9 commits into from
Jun 20, 2018
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
reactive-var@1.0.11
accounts-password@1.5.0
tap:i18n
smoral:sweetalert
ecmascript@0.10.6
es5-shim@4.7.0
standard-minifier-css@1.4.0
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 @@ session@1.1.7
sha@1.0.9
shell-server@0.3.1
shim-common@0.1.0
smoral:sweetalert@1.1.1
socket-stream-client@0.1.0
spacebars@1.0.15
spacebars-compiler@1.1.3
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
};
}
});