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, queuedForTyping: null,
_lastSimilaritySearch: null, _lastSimilaritySearch: null,
_similarTopicsMessage: null, _similarTopicsMessage: null,
_yourselfConfirm: null,
similarTopics: null, similarTopics: null,
hidden: Ember.computed.not('composer.viewOpen'), hidden: Ember.computed.not('composer.viewOpen'),
@ -83,6 +84,22 @@ export default Ember.Component.extend({
// Some messages only get shown after being typed. // Some messages only get shown after being typed.
_typedReply() { _typedReply() {
if (this.isDestroying || this.isDestroyed) { return; } 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)); 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> <a href {{action "closeMessage"}} class='close'>{{fa-icon "close"}}</a>
{{#if message.title}}<h3>{{message.title}}</h3>{{/if}}
<p>{{{message.body}}}</p> <p>{{{message.body}}}</p>

View file

@ -1090,6 +1090,9 @@ en:
modal_ok: "OK" modal_ok: "OK"
modal_cancel: "Cancel" modal_cancel: "Cancel"
cant_send_pm: "Sorry, you can't send a message to %{username}." 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" admin_options_title: "Optional staff settings for this topic"
auto_close: auto_close: