FEATURE: add support for `group_name` parameter in `/new-message` route

This commit is contained in:
Arpit Jalan 2018-05-28 13:24:53 +05:30
parent 123a22e6d8
commit 54338cfdcb
1 changed files with 5 additions and 4 deletions

View File

@ -6,6 +6,7 @@ export default Discourse.Route.extend({
beforeModel(transition) {
const self = this;
const params = transition.queryParams;
const groupName = params.groupname || params.group_name;
if (self.currentUser) {
self.replaceWith("discovery.latest").then(e => {
@ -20,13 +21,13 @@ export default Discourse.Route.extend({
}).catch(function() {
bootbox.alert(I18n.t("generic_error"));
});
} else if (params.groupname) {
} else if (groupName) {
// send a message to a group
Group.messageable(params.groupname).then(result => {
Group.messageable(groupName).then(result => {
if (result.messageable) {
Ember.run.next(() => e.send("createNewMessageViaParams", params.groupname, params.title, params.body));
Ember.run.next(() => e.send("createNewMessageViaParams", groupName, params.title, params.body));
} else {
bootbox.alert(I18n.t("composer.cant_send_pm", { username: params.groupname }));
bootbox.alert(I18n.t("composer.cant_send_pm", { username: groupName }));
}
}).catch(function() {
bootbox.alert(I18n.t("generic_error"));