From 455483a2990ea6ad53e4d8f589a642f9e81a285b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lindo=C3=A9lio=20L=C3=A1zaro?= Date: Fri, 8 Sep 2017 06:46:50 -0300 Subject: [PATCH] Add settings for allow user direct messages to yourself. --- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + packages/rocketchat-i18n/i18n/es.i18n.json | 1 + packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 1 + packages/rocketchat-i18n/i18n/pt.i18n.json | 1 + packages/rocketchat-lib/server/startup/settings.js | 4 ++++ server/methods/createDirectMessage.js | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 9413c0c42a0e..c865381601a2 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1065,6 +1065,7 @@ "Message_AllowDeleting": "Allow Message Deleting", "Message_AllowDeleting_BlockDeleteInMinutes": "Block Message Deleting After (n) Minutes", "Message_AllowDeleting_BlockDeleteInMinutes_Description": "Enter 0 to disable blocking.", + "Message_AllowDirectMessagesToYourself": "Allow user direct messages to yourself", "Message_AllowEditing": "Allow Message Editing", "Message_AllowEditing_BlockEditInMinutes": "Block Message Editing After (n) Minutes", "Message_AllowEditing_BlockEditInMinutesDescription": "Enter 0 to disable blocking.", diff --git a/packages/rocketchat-i18n/i18n/es.i18n.json b/packages/rocketchat-i18n/i18n/es.i18n.json index cbd1497ca6c1..1cdcd6ef31d5 100644 --- a/packages/rocketchat-i18n/i18n/es.i18n.json +++ b/packages/rocketchat-i18n/i18n/es.i18n.json @@ -777,6 +777,7 @@ "Message_AllowDeleting": "Permitir la eliminación de mensajes", "Message_AllowDeleting_BlockDeleteInMinutes": "Bloquear la Eliminación de Mensajes Despues de (n) Minutos", "Message_AllowDeleting_BlockDeleteInMinutes_Description": "Introduzca 0 para desactivar el bloqueo.", + "Message_AllowDirectMessagesToYourself": "Permita mensajes directos del usuario a usted mismo", "Message_AllowEditing": "Permitir la edición de mensajes", "Message_AllowEditing_BlockEditInMinutes": "Bloquear la Edicion de Mensajes Despues de (n) Minutos", "Message_AllowEditing_BlockEditInMinutesDescription": "Ingrese 0 para deshabilitar el bloqueo.", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 92e22c60c44a..8d97d77fecfc 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -727,6 +727,7 @@ "Message_AllowDeleting": "Permitir Exclusão de Mensagem", "Message_AllowDeleting_BlockDeleteInMinutes": "Bloquear exclusão de mensagens após (n) minutos", "Message_AllowDeleting_BlockDeleteInMinutes_Description": "Digite 0 para desativar o bloqueio.", + "Message_AllowDirectMessagesToYourself": "Permitir mensagens diretas do usuário para si mesmo", "Message_AllowEditing": "Permitir Edição de Mensagem", "Message_AllowEditing_BlockEditInMinutes": "Bloquear edição de mensagens após (em minutos - 0 para desabilitar)", "Message_AllowEditing_BlockEditInMinutesDescription": "Insira 0 para desabilitar o bloqueio.", diff --git a/packages/rocketchat-i18n/i18n/pt.i18n.json b/packages/rocketchat-i18n/i18n/pt.i18n.json index bec992f305ff..906ea94b297a 100644 --- a/packages/rocketchat-i18n/i18n/pt.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt.i18n.json @@ -771,6 +771,7 @@ "Message_AllowDeleting": "Permitir Exclusão de Mensagem", "Message_AllowDeleting_BlockDeleteInMinutes": "Bloquear exclusão de mensagens após (n) minutos", "Message_AllowDeleting_BlockDeleteInMinutes_Description": "Digite 0 para desativar o bloqueio.", + "Message_AllowDirectMessagesToYourself": "Permitir mensagens diretas do usuário para si mesmo", "Message_AllowEditing": "Permitir Edição de Mensagem", "Message_AllowEditing_BlockEditInMinutes": "Bloquear edição de mensagens após (em minutos - 0 para desabilitar)", "Message_AllowEditing_BlockEditInMinutesDescription": "Insira 0 para desabilitar o bloqueio.", diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index ec165002dc4d..f843f91d4cb7 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -1002,6 +1002,10 @@ RocketChat.settings.addGroup('Message', function() { type: 'boolean', 'public': true }); + this.add('Message_AllowDirectMessagesToYourself', true, { + type: 'boolean', + 'public': true + }); this.add('Message_AlwaysSearchRegExp', false, { type: 'boolean' }); diff --git a/server/methods/createDirectMessage.js b/server/methods/createDirectMessage.js index e49c9ad17738..1dd43f293b02 100644 --- a/server/methods/createDirectMessage.js +++ b/server/methods/createDirectMessage.js @@ -16,7 +16,7 @@ Meteor.methods({ }); } - if (me.username === username) { + if (RocketChat.settings.get('Message_AllowDirectMessagesToYourself') === false && me.username === username) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'createDirectMessage' });