FEATURE: Enforce mention limits for chat messages (#19034)
* FEATURE: Enforce mention limits for chat messages The first part of these changes adds a new setting called `max_mentions_per_chat_message`, which skips notifications when the message contains too many mentions. It also respects the `max_users_notified_per_group_mention` setting and skips notifications if expanding a group mention would exceed it. We also include a new component to display JIT warning for these limits to the user while composing a message. * Simplify ignoring/muting filter in chat_notifier * Post-send warnings for unsent warnings * Improve pluralization * Address review feedback * Fix test * Address second feedback round * Third round of feedback Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
chatChannelPretender,
|
||||
} from "../helpers/chat-pretenders";
|
||||
|
||||
const GROUP_NAME = "group1";
|
||||
|
||||
acceptance("Discourse Chat - Composer", function (needs) {
|
||||
needs.user({ has_chat_enabled: true });
|
||||
needs.settings({ chat_enabled: true, enable_rich_text_paste: true });
|
||||
@@ -32,6 +34,14 @@ acceptance("Discourse Chat - Composer", function (needs) {
|
||||
server.post("/chat/drafts", () => {
|
||||
return helper.response([]);
|
||||
});
|
||||
|
||||
server.get("/chat/api/mentions/groups.json", () => {
|
||||
return helper.response({
|
||||
unreachable: [GROUP_NAME],
|
||||
over_members_limit: [],
|
||||
invalid: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
needs.hooks.beforeEach(function () {
|
||||
@@ -105,6 +115,18 @@ acceptance("Discourse Chat - Composer", function (needs) {
|
||||
"it tracks the emoji"
|
||||
);
|
||||
});
|
||||
|
||||
test("JIT warnings for group mentions", async function (assert) {
|
||||
await visit("/chat/channel/11/-");
|
||||
await fillIn(".chat-composer-input", `@${GROUP_NAME}`);
|
||||
|
||||
assert.equal(
|
||||
query(".chat-mention-warnings .chat-mention-warnings-list__simple li")
|
||||
.innerText,
|
||||
`@${GROUP_NAME} doesn't allow mentions`,
|
||||
"displays a warning when the group is unreachable"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
let sendAttempt = 0;
|
||||
|
||||
@@ -864,7 +864,7 @@ Widget.triangulate(arg: "test")
|
||||
".chat-message-container[data-id='176'] .chat-message-mention-warning .without-membership"
|
||||
).innerText;
|
||||
assert.ok(withoutMembershipText.includes("eviltrout"));
|
||||
assert.ok(withoutMembershipText.includes("sam"));
|
||||
assert.ok(withoutMembershipText.includes("1 other"));
|
||||
|
||||
await click(
|
||||
".chat-message-container[data-id='176'] .chat-message-mention-warning .invite-link"
|
||||
|
||||
Reference in New Issue
Block a user