mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FEATURE: allow sending message via a link to multiple users (#15412)
https://meta.discourse.org/t/possible-to-compose-pre-filled-multi-user-private-message-via-url/78020
This commit is contained in:
parent
c330363e14
commit
b75cbec4b6
@ -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)
|
||||
|
@ -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"
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user