Add a warning if a user tries to PM themselves

This commit is contained in:
Robin Ward 2016-08-03 13:58:24 -04:00
parent 5f67cd7b45
commit 19fa24d888
3 changed files with 21 additions and 0 deletions

View File

@ -8,6 +8,7 @@ export default Ember.Component.extend({
queuedForTyping: null,
_lastSimilaritySearch: null,
_similarTopicsMessage: null,
_yourselfConfirm: null,
similarTopics: null,
hidden: Ember.computed.not('composer.viewOpen'),
@ -83,6 +84,22 @@ export default Ember.Component.extend({
// Some messages only get shown after being typed.
_typedReply() {
if (this.isDestroying || this.isDestroyed) { return; }
const composer = this.get('composer');
if (composer.get('privateMessage')) {
const usernames = composer.get('targetUsernames').split(',');
if (usernames.length === 1 && usernames[0] === this.currentUser.get('username')) {
const message = this._yourselfConfirm || composer.store.createRecord('composer-message', {
id: 'yourself_confirm',
templateName: 'custom-body',
title: I18n.t('composer.yourself_confirm.title'),
body: I18n.t('composer.yourself_confirm.body')
});
this.send('popup', message);
}
}
this.get('queuedForTyping').forEach(msg => this.send("popup", msg));
},

View File

@ -1,2 +1,3 @@
<a href {{action "closeMessage"}} class='close'>{{fa-icon "close"}}</a>
{{#if message.title}}<h3>{{message.title}}</h3>{{/if}}
<p>{{{message.body}}}</p>

View File

@ -1090,6 +1090,9 @@ en:
modal_ok: "OK"
modal_cancel: "Cancel"
cant_send_pm: "Sorry, you can't send a message to %{username}."
yourself_confirm:
title: "Did you forget to add recipients?"
body: "Right now this message is only being sent to yourself!"
admin_options_title: "Optional staff settings for this topic"
auto_close: