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
8 changes: 7 additions & 1 deletion app/livechat/client/views/app/livechatDepartmentForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
<label><input type="radio" name="showOnOfflineForm" value="0" checked="{{showOnOfflineForm false}}" /> {{_ "No"}}</label>
</div>
</div>

<div class="input-line">
<label>{{_ "Request_tag_before_closing_chat"}}</label>
<div>
<label><input type="radio" name="requestTagBeforeClosingChat" value="1" checked="{{$eq requestTagBeforeClosingChat true}}" /> {{_ "Yes"}}</label>
<label><input type="radio" name="requestTagBeforeClosingChat" value="0" checked="{{$eq requestTagBeforeClosingChat false}}" /> {{_ "No"}}</label>
</div>
</div>
{{#if customFieldsTemplate}}
{{> Template.dynamic template=customFieldsTemplate data=data }}
{{/if}}
Expand Down
6 changes: 6 additions & 0 deletions app/livechat/client/views/app/livechatDepartmentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Template.livechatDepartmentForm.helpers({
const department = Template.instance().department.get();
return department.showOnOfflineForm === value || (department.showOnOfflineForm === undefined && value === true);
},
requestTagBeforeClosingChat() {
const department = Template.instance().department.get();
return !!(department && department.requestTagBeforeClosingChat);
},
customFieldsTemplate() {
return getCustomFormTemplate('livechatDepartmentForm');
},
Expand Down Expand Up @@ -81,6 +85,7 @@ Template.livechatDepartmentForm.events({
const showOnRegistration = instance.$('input[name=showOnRegistration]:checked').val();
const email = instance.$('input[name=email]').val();
const showOnOfflineForm = instance.$('input[name=showOnOfflineForm]:checked').val();
const requestTagBeforeClosingChat = instance.$('input[name=requestTagBeforeClosingChat]:checked').val();

if (enabled !== '1' && enabled !== '0') {
return toastr.error(t('Please_select_enabled_yes_or_no'));
Expand All @@ -100,6 +105,7 @@ Template.livechatDepartmentForm.events({
description: description.trim(),
showOnRegistration: showOnRegistration === '1',
showOnOfflineForm: showOnOfflineForm === '1',
requestTagBeforeClosingChat: requestTagBeforeClosingChat === '1',
email: email.trim(),
};
}
Expand Down
22 changes: 22 additions & 0 deletions app/livechat/server/hooks/beforeCloseRoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Meteor } from 'meteor/meteor';

import { callbacks } from '../../../callbacks';
import { LivechatDepartment } from '../../../models';

callbacks.add('livechat.beforeCloseRoom', (room) => {
const { departmentId } = room;
if (!departmentId) {
return room;
}

const department = LivechatDepartment.findOneById(departmentId);
if (!department || !department.requestTagBeforeClosingChat) {
return room;
}

if (room.tags && room.tags.length > 0) {
return room;
}

throw new Meteor.Error('error-tags-must-be-assigned-before-closing-chat', 'Tag(s) must be assigned before closing the chat', { method: 'livechat.beforeCloseRoom' });
}, callbacks.priority.HIGH, 'livechat-before-close-Room');
1 change: 1 addition & 0 deletions app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import './permissions';
import '../lib/messageTypes';
import './config';
import './roomType';
import './hooks/beforeCloseRoom';
import './hooks/beforeGetNextAgent';
import './hooks/externalMessage';
import './hooks/leadCapture';
Expand Down
3 changes: 3 additions & 0 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ export const Livechat = {
if (!room || room.t !== 'l' || !room.open) {
return false;
}

callbacks.run('livechat.beforeCloseRoom', room);

const now = new Date();

const closeData = {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@
"error-password-policy-not-met-repeatingCharacters": "Password not not meet the server's policy of forbidden repeating characters (you have too many of the same characters next to each other)",
"error-push-disabled": "Push is disabled",
"error-remove-last-owner": "This is the last owner. Please set a new owner before removing this one.",
"error-tags-must-be-assigned-before-closing-chat": "Tag(s) must be assigned before closing the chat",
"error-role-in-use": "Cannot delete role because it's in use",
"error-role-name-required": "Role name is required",
"error-room-is-not-closed": "Room is not closed",
Expand Down Expand Up @@ -2608,6 +2609,7 @@
"Report_this_message_question_mark": "Report this message?",
"Reporting": "Reporting",
"Request_comment_when_closing_conversation": "Request comment when closing conversation",
"Request_tag_before_closing_chat": "Request tag(s) before closing conversation",
"Require_all_tokens": "Require all tokens",
"Require_any_token": "Require any token",
"Require_password_change": "Require password change",
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@
"error-password-policy-not-met-repeatingCharacters": "A senha não está de acordo com a política do servidor, relativamente aos caracteres proibidos repetidos (existem vários caracteres proibidos próximos uns dos outros)",
"error-push-disabled": "Notificações push desativadas",
"error-remove-last-owner": "Este é o último proprietário. Por favor, defina um novo proprietário antes de remover este.",
"error-tags-must-be-assigned-before-closing-chat": "É obrigatório atribuir tag(s) antes de encerrar a conversa",
"error-role-in-use": "Não é possível remover o papel pois ele está em uso",
"error-role-name-required": "Nome do papel é obrigatório",
"error-room-is-not-closed": "Sala não está fechada",
Expand Down Expand Up @@ -2449,6 +2450,7 @@
"Report_sent": "Relatório enviado",
"Report_this_message_question_mark": "Denunciar esta mensagem?",
"Reporting": "Relatórios",
"Request_comment_when_closing_conversation": "Solicitar comentário ao encerrar a conversa",
"Require_all_tokens": "Exigir todos os tokens",
"Require_any_token": "Exigir qualquer token",
"Require_password_change": "Exigir alteração de senha",
Expand Down Expand Up @@ -2790,6 +2792,7 @@
"Sync_Users": "Sincronizar Usuários",
"System_messages": "Mensagens do sistema",
"Tag": "Tag",
"Request_tag_before_closing_chat": "Solicitar tag(s) antes de encerrar a conversa",
"Take_it": "Pegue!",
"TargetRoom": "Sala de destino",
"TargetRoom_Description": "A sala onde as mensagens serão enviadas, que são o resultado desse evento a ser disparado. Somente uma sala alvo é permitida e deve existir.",
Expand Down