aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2022-03-15 06:51:53 +0300
committerRblSb <msrblsb@gmail.com>2022-03-15 06:51:53 +0300
commit79f3c34d24d6ae6aba17dd643726e20754140d80 (patch)
treed6b1d23bcfbdc023fc757f25b1b3fa085fd5e790 /build
parent692e4690abc2083d151c011a2df2976ecf6886cc (diff)
Update locked playlist restrictions
And add "toggleItemType" permission. Closes #36
Diffstat (limited to 'build')
-rw-r--r--build/server.js72
1 files changed, 48 insertions, 24 deletions
diff --git a/build/server.js b/build/server.js
index f1da10d..955c5cb 100644
--- a/build/server.js
+++ b/build/server.js
@@ -27,7 +27,22 @@ var Client = function(ws,req,id,name,group) {
};
Client.__name__ = true;
Client.prototype = {
- setGroupFlag: function(type,flag) {
+ hasPermission: function(permission,permissions) {
+ if((this.group & 1) != 0) {
+ return permissions.banned.indexOf(permission) != -1;
+ }
+ if((this.group & 8) != 0) {
+ return permissions.admin.indexOf(permission) != -1;
+ }
+ if((this.group & 4) != 0) {
+ return permissions.leader.indexOf(permission) != -1;
+ }
+ if((this.group & 2) != 0) {
+ return permissions.user.indexOf(permission) != -1;
+ }
+ return permissions.guest.indexOf(permission) != -1;
+ }
+ ,setGroupFlag: function(type,flag) {
if(flag) {
this.group |= 1 << type._hx_index;
} else {
@@ -72,21 +87,6 @@ ClientTools.getByName = function(clients,name,def) {
}
return def;
};
-ClientTools.hasPermission = function(client,permission,permissions) {
- if((client.group & 1) != 0) {
- return permissions.banned.indexOf(permission) != -1;
- }
- if((client.group & 8) != 0) {
- return permissions.admin.indexOf(permission) != -1;
- }
- if((client.group & 4) != 0) {
- return permissions.leader.indexOf(permission) != -1;
- }
- if((client.group & 2) != 0) {
- return permissions.user.indexOf(permission) != -1;
- }
- return permissions.guest.indexOf(permission) != -1;
-};
var DateTools = function() { };
DateTools.__name__ = true;
DateTools.__format_get = function(d,e) {
@@ -1857,7 +1857,7 @@ JsonParser_$67.prototype = $extend(json2object_reader_BaseParser.prototype,{
this.value = null;
}
,loadJsonString: function(s,pos,variable) {
- this.value = this.loadString(s,pos,variable,["guest","user","leader","admin","writeChat","addVideo","removeVideo","requestLeader","rewind","clearChat","setLeader","changeOrder","lockPlaylist","banClient"],"guest");
+ this.value = this.loadString(s,pos,variable,["guest","user","leader","admin","writeChat","addVideo","removeVideo","requestLeader","rewind","clearChat","setLeader","changeOrder","toggleItemType","lockPlaylist","banClient"],"guest");
}
,__class__: JsonParser_$67
});
@@ -4338,13 +4338,11 @@ server_Main.prototype = {
this.logger.log({ clientName : client.name, clientGroup : client.group, event : data, time : HxOverrides.dateStr(new Date())});
switch(data.type) {
case "AddVideo":
- if(!this.checkPermission(client,"addVideo")) {
+ if(this.isPlaylistLockedFor(client)) {
return;
}
- if(!this.videoList.isOpen) {
- if(!this.checkPermission(client,"lockPlaylist")) {
- return;
- }
+ if(!this.checkPermission(client,"addVideo")) {
+ return;
}
if(this.config.totalVideoLimit != 0 && this.videoList.items.length >= this.config.totalVideoLimit) {
this.serverMessage(client,"totalVideoLimitError");
@@ -4415,6 +4413,9 @@ server_Main.prototype = {
this.broadcast(data);
break;
case "ClearPlaylist":
+ if(this.isPlaylistLockedFor(client)) {
+ return;
+ }
if(!this.checkPermission(client,"removeVideo")) {
return;
}
@@ -4642,6 +4643,9 @@ server_Main.prototype = {
this.broadcast(data);
break;
case "RemoveVideo":
+ if(this.isPlaylistLockedFor(client)) {
+ return;
+ }
if(!this.checkPermission(client,"removeVideo")) {
return;
}
@@ -4707,6 +4711,9 @@ server_Main.prototype = {
}
break;
case "SetNextItem":
+ if(this.isPlaylistLockedFor(client)) {
+ return;
+ }
if(!this.checkPermission(client,"changeOrder")) {
return;
}
@@ -4741,6 +4748,9 @@ server_Main.prototype = {
this.broadcastExcept(client,{ type : data.type, setTime : data.setTime});
break;
case "ShufflePlaylist":
+ if(this.isPlaylistLockedFor(client)) {
+ return;
+ }
if(!this.checkPermission(client,"changeOrder")) {
return;
}
@@ -4757,6 +4767,12 @@ server_Main.prototype = {
this.skipVideo(data);
break;
case "ToggleItemType":
+ if(this.isPlaylistLockedFor(client)) {
+ return;
+ }
+ if(!this.checkPermission(client,"toggleItemType")) {
+ return;
+ }
this.videoList.toggleItemType(data.toggleItemType.pos);
this.broadcast(data);
break;
@@ -4834,7 +4850,7 @@ server_Main.prototype = {
if((client.group & 1) != 0) {
this.checkBan(client);
}
- var state = ClientTools.hasPermission(client,perm,this.config.permissions);
+ var state = client.hasPermission(perm,this.config.permissions);
if(!state) {
this.send(client,{ type : "ServerMessage", serverMessage : { textId : "accessError"}});
}
@@ -4859,7 +4875,7 @@ server_Main.prototype = {
client.setGroupFlag(ClientGroup.Banned,!isOutdated);
if(isOutdated) {
HxOverrides.remove(this.userList.bans,ban);
- haxe_Log.trace("" + client.name + " ban removed",{ fileName : "src/server/Main.hx", lineNumber : 923, className : "server.Main", methodName : "checkBan"});
+ haxe_Log.trace("" + client.name + " ban removed",{ fileName : "src/server/Main.hx", lineNumber : 927, className : "server.Main", methodName : "checkBan"});
this.sendClientList();
}
break;
@@ -4927,6 +4943,14 @@ server_Main.prototype = {
this.videoTimer.setTime(this.flashbackTime);
this.flashbackTime = time;
}
+ ,isPlaylistLockedFor: function(client) {
+ if(!this.videoList.isOpen) {
+ if(!this.checkPermission(client,"lockPlaylist")) {
+ return true;
+ }
+ }
+ return false;
+ }
,__class__: server_Main
};
var server_Utils = function() { };
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage