Add delay to whitelist warning message to prevent spamming

This commit is contained in:
q 2024-04-27 15:00:29 -04:00
parent 3dc55070f7
commit 49b80f6323

View File

@ -127,7 +127,14 @@ Searxng.prototype.handleMessage = function(event, room) {
return; return;
} }
else if (this.roomUserWhitelists.has(room.roomId) && this.roomUserWhitelists.get(room.roomId).indexOf(event.getSender()) < 0) { else if (this.roomUserWhitelists.has(room.roomId) && this.roomUserWhitelists.get(room.roomId).indexOf(event.getSender()) < 0) {
this.matrixClient.sendNotice(room.roomId, "You are not on the whitelist for this room."); const lastRoomWarningTime = lastWarningTimes.get(room.roomId);
const currentTime = Date.now();
if (isNaN(lastRoomWarningTime) || (Date.now() - lastRoomWarningTime) > 10000) {
this.matrixClient.sendNotice(room.roomId, "You are not on the whitelist for this room.");
lastWarningTimes.set(room.roomId, currentTime);
}
return; return;
} }
else if (this.cooldownImmuneUsers.indexOf(event.getSender()) < 0) { else if (this.cooldownImmuneUsers.indexOf(event.getSender()) < 0) {