Skip to content

Commit

Permalink
FEATURE: allow sending message via a link to multiple users (#15412)
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitjalan committed Dec 28, 2021
1 parent c330363 commit b75cbec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
24 changes: 5 additions & 19 deletions 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";
Expand All @@ -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)
Expand Down
Expand Up @@ -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");
Expand All @@ -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"
);
});
Expand Down

1 comment on commit b75cbec

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/possible-to-compose-pre-filled-multi-user-private-message-via-url/78020/11

Please sign in to comment.