FEATURE: custom email message for topic invites

This commit is contained in:
Arpit Jalan
2016-06-07 22:54:45 +05:30
parent b624c5cc94
commit 4253141700
7 changed files with 104 additions and 54 deletions

View File

@@ -74,10 +74,9 @@ export default Ember.Controller.extend(ModalFunctionality, {
return this.get('isAdmin') && (Discourse.Utilities.emailValid(this.get('emailOrUsername')) || this.get('isPrivateTopic') || !this.get('invitingToTopic')) && !Discourse.SiteSettings.enable_sso && Discourse.SiteSettings.enable_local_logins && !this.get('isMessage');
}.property('isAdmin', 'emailOrUsername', 'isPrivateTopic', 'isMessage', 'invitingToTopic'),
// Show Custom Message textarea? (only shown when inviting new user to forum)
showCustomMessage: function() {
return this.get('model') === this.currentUser;
}.property('model'),
return (this.get('model') === this.currentUser || Discourse.Utilities.emailValid(this.get('emailOrUsername')));
}.property('emailOrUsername'),
// Instructional text for the modal.
inviteInstructions: function() {
@@ -228,7 +227,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
showCustomMessageBox() {
this.toggleProperty('hasCustomMessage');
if (this.get('hasCustomMessage')) {
this.set('customMessage', I18n.t('invite.custom_message_template'));
if (this.get('model') === this.currentUser) {
this.set('customMessage', I18n.t('invite.custom_message_template_forum'));
} else {
this.set('customMessage', I18n.t('invite.custom_message_template_topic'));
}
} else {
this.set('customMessage', null);
}

View File

@@ -309,10 +309,10 @@ const Topic = RestModel.extend({
});
},
createInvite(emailOrUsername, groupNames) {
createInvite(user, group_names, custom_message) {
return Discourse.ajax("/t/" + this.get('id') + "/invite", {
type: 'POST',
data: { user: emailOrUsername, group_names: groupNames }
data: { user, group_names, custom_message }
});
},