mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -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 DiscourseRoute from "discourse/routes/discourse";
|
||||||
import Group from "discourse/models/group";
|
import Group from "discourse/models/group";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import User from "discourse/models/user";
|
|
||||||
import bootbox from "bootbox";
|
import bootbox from "bootbox";
|
||||||
import cookie from "discourse/lib/cookie";
|
import cookie from "discourse/lib/cookie";
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
@ -15,24 +14,11 @@ export default DiscourseRoute.extend({
|
|||||||
if (this.currentUser) {
|
if (this.currentUser) {
|
||||||
this.replaceWith("discovery.latest").then((e) => {
|
this.replaceWith("discovery.latest").then((e) => {
|
||||||
if (params.username) {
|
if (params.username) {
|
||||||
// send a message to a user
|
e.send("createNewMessageViaParams", {
|
||||||
User.findByUsername(encodeURIComponent(params.username))
|
recipients: params.username,
|
||||||
.then((user) => {
|
topicTitle: params.title,
|
||||||
if (user.can_send_private_message_to_user) {
|
topicBody: params.body,
|
||||||
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")));
|
|
||||||
} else if (groupName) {
|
} else if (groupName) {
|
||||||
// send a message to a group
|
// send a message to a group
|
||||||
Group.messageable(groupName)
|
Group.messageable(groupName)
|
||||||
|
@ -22,7 +22,7 @@ acceptance("New Message - Authenticated", function (needs) {
|
|||||||
|
|
||||||
test("accessing new-message route when logged in", async function (assert) {
|
test("accessing new-message route when logged in", async function (assert) {
|
||||||
await visit(
|
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");
|
assert.ok(exists(".composer-fields"), "it opens composer");
|
||||||
@ -40,7 +40,7 @@ acceptance("New Message - Authenticated", function (needs) {
|
|||||||
const privateMessageUsers = selectKit("#private-message-users");
|
const privateMessageUsers = selectKit("#private-message-users");
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
privateMessageUsers.header().value(),
|
privateMessageUsers.header().value(),
|
||||||
"charlie",
|
"charlie,john",
|
||||||
"it selects correct username"
|
"it selects correct username"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user