Move operator

This commit is contained in:
Will Hunt 2024-09-19 22:28:11 +01:00
parent 5d497b4ca0
commit ec0c8b7484
2 changed files with 3 additions and 3 deletions

View File

@ -50,7 +50,7 @@ export class MentionSpam extends Protection {
let found = 0;
for (const word of body.split(/\s/)) {
if (USER_ID_REGEX.test(word.trim())) {
if (found++ > max) {
if (++found > max) {
return true;
}
}
@ -60,7 +60,7 @@ export class MentionSpam extends Protection {
let found = 0;
for (const word of htmlBody.split(/\s/)) {
if (USER_ID_REGEX.test(word.trim())) {
if (found++ > max) {
if (++found > max) {
return true;
}
}

View File

@ -71,7 +71,7 @@ describe("Test: Mention spam protection", function () {
});
// Also covers HTML mentions
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, {
msgtype: 'm.text',
body: 'Hello world',