Adding per-room whitelists to only allow some users to search
This commit is contained in:
6
index.js
6
index.js
@@ -5,6 +5,7 @@ function Searxng(matrixClient) {
|
||||
this.blacklistedUimgRooms = [];
|
||||
this.cooldownImmuneUsers = [];
|
||||
this.roomCooldowns = new Map();
|
||||
this.roomUserWhitelists = new Map();
|
||||
this.searxngInstance = "";
|
||||
this.searxngParameters = "enabled_engines=duckduckgo images__images,google images__images,bing images__images&disabled_engines=flickr__images,nyaa__images,qwant images__images,artic__images,deviantart__images,library of congress__images,unsplash__images,openverse__images"
|
||||
}
|
||||
@@ -14,6 +15,7 @@ Searxng.prototype.setBlacklistedImgRooms = function(blacklistedImgRooms){ this.b
|
||||
Searxng.prototype.setBlacklistedUimgRooms = function(blacklistedUimgRooms){ this.blacklistedUimgRooms = blacklistedUimgRooms; };
|
||||
Searxng.prototype.setCooldownImmuneUsers = function(cooldownImmuneUsers){ this.cooldownImmuneUsers = cooldownImmuneUsers; };
|
||||
Searxng.prototype.setRoomCooldowns = function(roomCooldowns){ this.roomCooldowns = roomCooldowns; };
|
||||
Searxng.prototype.setRoomUserWhitelists = function(roomUserWhitelists){ this.roomUserWhitelists = roomUserWhitelists; };
|
||||
Searxng.prototype.setSearxngInstance = function(searxngInstance){ this.searxngInstance = searxngInstance; };
|
||||
Searxng.prototype.setSearxngParameters = function(searxngParameters){ this.searxngParameters = searxngParameters; };
|
||||
|
||||
@@ -124,6 +126,10 @@ Searxng.prototype.handleMessage = function(event, room) {
|
||||
console.warn("Don't have permission to post in room "+room.roomId);
|
||||
return;
|
||||
}
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
else if (this.cooldownImmuneUsers.indexOf(event.getSender()) < 0) {
|
||||
const roomCooldown = this.roomCooldowns.get(room.roomId);
|
||||
|
||||
|
Reference in New Issue
Block a user