mirror of https://github.com/calzoneman/sync.git
Add ability to blacklist channels in site config
This commit is contained in:
parent
7dde8cffe9
commit
4c1b8e8c1a
|
@ -171,3 +171,7 @@ contacts:
|
|||
# periodically, the garbage collector will be invoked immediately.
|
||||
# The server must be invoked with node --expose-gc index.js for this to have any effect.
|
||||
aggressive-gc: false
|
||||
|
||||
# Allows you to blacklist certain channels. Users will be automatically kicked
|
||||
# upon trying to join one.
|
||||
channel-blacklist: []
|
||||
|
|
|
@ -103,7 +103,8 @@ var defaults = {
|
|||
playlist: {
|
||||
"max-items": 4000,
|
||||
"update-interval": 5
|
||||
}
|
||||
},
|
||||
"channel-blacklist": []
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -324,6 +325,14 @@ function preprocessConfig(cfg) {
|
|||
reserved[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert channel blacklist to a hashtable */
|
||||
var tbl = {};
|
||||
cfg["channel-blacklist"].forEach(function (c) {
|
||||
tbl[c.toLowerCase()] = true;
|
||||
});
|
||||
cfg["channel-blacklist"] = tbl;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ function User(socket) {
|
|||
}
|
||||
|
||||
data.name = data.name.toLowerCase();
|
||||
if (data.name in Config.get("channel-blacklist")) {
|
||||
self.kick("This channel is blacklisted.");
|
||||
}
|
||||
|
||||
self.waitFlag(Flags.U_READY, function () {
|
||||
var chan = Server.getServer().getChannel(data.name);
|
||||
chan.joinUser(self, data);
|
||||
|
|
Loading…
Reference in New Issue