Adding per-room whitelists to only allow some users to search
This commit is contained in:
parent
4bd43a9630
commit
3dc55070f7
@ -31,6 +31,15 @@ searx.setRoomCooldowns(new Map([
|
||||
searx.setSearxInstance("https://searx.example.com");
|
||||
searx.setSearxParameters("disabled_engines=flickr__images");
|
||||
|
||||
searxng.setRoomUserWhitelists(new Map([
|
||||
["!blahblahblah:midov.pl",
|
||||
[
|
||||
"@q:glowers.club",
|
||||
"@midek:midov.pl"
|
||||
]
|
||||
]
|
||||
]));
|
||||
|
||||
matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline) {
|
||||
if (event.getTs() >= startupTime && event.getType() == "m.room.message" && event.getContent().body != null) {
|
||||
|
||||
|
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user