mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Move operator
This commit is contained in:
parent
5d497b4ca0
commit
ec0c8b7484
@ -50,7 +50,7 @@ export class MentionSpam extends Protection {
|
|||||||
let found = 0;
|
let found = 0;
|
||||||
for (const word of body.split(/\s/)) {
|
for (const word of body.split(/\s/)) {
|
||||||
if (USER_ID_REGEX.test(word.trim())) {
|
if (USER_ID_REGEX.test(word.trim())) {
|
||||||
if (found++ > max) {
|
if (++found > max) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ export class MentionSpam extends Protection {
|
|||||||
let found = 0;
|
let found = 0;
|
||||||
for (const word of htmlBody.split(/\s/)) {
|
for (const word of htmlBody.split(/\s/)) {
|
||||||
if (USER_ID_REGEX.test(word.trim())) {
|
if (USER_ID_REGEX.test(word.trim())) {
|
||||||
if (found++ > max) {
|
if (++found > max) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ describe("Test: Mention spam protection", function () {
|
|||||||
});
|
});
|
||||||
// Also covers HTML mentions
|
// Also covers HTML mentions
|
||||||
const mentionUsers = Array.from({length: DEFAULT_MAX_MENTIONS+1}, (_, i) => `@user${i}:example.org`);
|
const mentionUsers = Array.from({length: DEFAULT_MAX_MENTIONS+1}, (_, i) => `@user${i}:example.org`);
|
||||||
const messageWithTextMentions = await client.sendText(room, 'Hello world ' + mentionUsers.join(' '));
|
const messageWithTextMentions = await client.sendText(room, mentionUsers.join(' '));
|
||||||
const messageWithMMentions = await client.sendMessage(room, {
|
const messageWithMMentions = await client.sendMessage(room, {
|
||||||
msgtype: 'm.text',
|
msgtype: 'm.text',
|
||||||
body: 'Hello world',
|
body: 'Hello world',
|
||||||
|
Loading…
Reference in New Issue
Block a user