diff --git a/app/assets/javascripts/discourse/app/routes/new-message.js b/app/assets/javascripts/discourse/app/routes/new-message.js index aec1774cc4c..f7e32b53417 100644 --- a/app/assets/javascripts/discourse/app/routes/new-message.js +++ b/app/assets/javascripts/discourse/app/routes/new-message.js @@ -1,7 +1,6 @@ import DiscourseRoute from "discourse/routes/discourse"; import Group from "discourse/models/group"; import I18n from "I18n"; -import User from "discourse/models/user"; import bootbox from "bootbox"; import cookie from "discourse/lib/cookie"; import { next } from "@ember/runloop"; @@ -15,24 +14,11 @@ export default DiscourseRoute.extend({ if (this.currentUser) { this.replaceWith("discovery.latest").then((e) => { if (params.username) { - // send a message to a user - User.findByUsername(encodeURIComponent(params.username)) - .then((user) => { - if (user.can_send_private_message_to_user) { - next(() => - e.send("createNewMessageViaParams", { - recipients: user.username, - topicTitle: params.title, - topicBody: params.body, - }) - ); - } else { - bootbox.alert( - I18n.t("composer.cant_send_pm", { username: user.username }) - ); - } - }) - .catch(() => bootbox.alert(I18n.t("generic_error"))); + e.send("createNewMessageViaParams", { + recipients: params.username, + topicTitle: params.title, + topicBody: params.body, + }); } else if (groupName) { // send a message to a group Group.messageable(groupName) diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js index 9ecd8abb17d..185850c5117 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js @@ -22,7 +22,7 @@ acceptance("New Message - Authenticated", function (needs) { test("accessing new-message route when logged in", async function (assert) { await visit( - "/new-message?username=charlie&title=message%20title&body=message%20body" + "/new-message?username=charlie,john&title=message%20title&body=message%20body" ); assert.ok(exists(".composer-fields"), "it opens composer"); @@ -40,7 +40,7 @@ acceptance("New Message - Authenticated", function (needs) { const privateMessageUsers = selectKit("#private-message-users"); assert.strictEqual( privateMessageUsers.header().value(), - "charlie", + "charlie,john", "it selects correct username" ); });