Duplicate song queue adds can be blocked
This commit is contained in:
parent
1e1eac4aa4
commit
bcd6807a34
2 changed files with 22 additions and 8 deletions
|
|
@ -332,7 +332,11 @@ async function submitSong(songid) {
|
|||
let returncode = await getFromServer({song: songid}, "songadd");
|
||||
if(returncode == ERR_NO_ADMIN) {
|
||||
// right now the error is alerted in getFromServer, maybe will change that
|
||||
} else {
|
||||
}
|
||||
else if(returncode["error"]=="song-in-queue") {
|
||||
alertText("That song's about to play! Hang on!")
|
||||
}
|
||||
else {
|
||||
alertText("Added to Queue");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from flask import Flask
|
|||
from flask import request
|
||||
from flask_cors import CORS
|
||||
import sqlite3 as sql
|
||||
import vlc,threading,time,random,argparse,dotenv,os,hashlib
|
||||
import vlc,threading,time,random,argparse,dotenv,os,hashlib,string
|
||||
# Argparse Stuff
|
||||
parser=argparse.ArgumentParser(description="Options for the Webby Bits")
|
||||
# parser.add_argument('-p','--port',help="Port to host on, not the same as the web (client) port",default='19054')
|
||||
|
|
@ -14,9 +14,13 @@ portTheUserPicked=os.getenv("SERVER_PORT")
|
|||
# This is not great design, and the whole "returning string codes" thing is something to add to the todo list
|
||||
# I mean returning 200 when no return is necesary i think is fine but we'll see
|
||||
ERR_NO_ADMIN = "401"
|
||||
ADMIN_PASS = hashlib.sha256(bytes(args.admin,'utf-8')).hexdigest()
|
||||
if not(ADMIN_PASS):
|
||||
ADMIN_PASS = None
|
||||
if args.admin:
|
||||
ADMIN_PASS = hashlib.sha256(bytes(args.admin,'utf-8')).hexdigest()
|
||||
else:
|
||||
tempPass = ''.join(random.choices(string.ascii_letters + string.digits +"?"+"!",k=20))
|
||||
print("No adminPass was set, the auto generated one is: "+tempPass)
|
||||
ADMIN_PASS = hashlib.sha256(bytes(tempPass,'utf-8')).hexdigest()
|
||||
|
||||
# True = everyone, False = admin only. Change in client while in use.
|
||||
# play-pause,skip,addsong,partymode,volume in order
|
||||
controlPerms = {
|
||||
|
|
@ -190,8 +194,14 @@ def songadd():
|
|||
recieveData=request.get_json(force=True)
|
||||
if (ADMIN_PASS and ADMIN_PASS == recieveData['password']) or controlPerms["AS"]:
|
||||
# Password exists and is correct, or it's not restricted
|
||||
queueSong(recieveData['song'])
|
||||
return "200"
|
||||
# if (recieveData['song'] in playlist):
|
||||
# return {"error":"song-in-queue"}
|
||||
# else:
|
||||
# Right now the above is disabled since i want to make it optional first
|
||||
# probably with a checkbox like the other admin controls
|
||||
if True:
|
||||
queueSong(recieveData['song'])
|
||||
return "200"
|
||||
else:
|
||||
# the password is incorrect (technically a password not existing falls into the above case because controlPerms is never changed)
|
||||
return ERR_NO_ADMIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue