mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Added more info on faulty input
- Sent in the results on REST - Sent in the update_required msg on socket.io connection
This commit is contained in:
386
server/README.md
386
server/README.md
@@ -2,391 +2,11 @@
|
|||||||
|
|
||||||
Under ``` /server/apps/ ```, there are two files, ``` admin.js ``` and ``` client.js ```.``` admin.js ``` are for the adminpanel, and ``` client.js ``` are for zoff itself.
|
Under ``` /server/apps/ ```, there are two files, ``` admin.js ``` and ``` client.js ```.``` admin.js ``` are for the adminpanel, and ``` client.js ``` are for zoff itself.
|
||||||
|
|
||||||
|
|
||||||
## REST
|
## REST
|
||||||
|
|
||||||
All PUT, DELETE and POST endpoints have a 1-second waitlimit for each command per client. You'll get a response with Retry-After header for how long you have to wait. Shuffling in a player has a 5-second waitlimit, but per channel instead of per client.
|
[Rest API info](REST.md)
|
||||||
|
|
||||||
If you want to skip the wait-times, create a token at <a href="https://zoff.me/api/apply">https://zoff.me/api/apply</a>. Tokens are added to all the POST, PUT, DELETE, requests as ``` token: TOKEN ```.
|
|
||||||
|
|
||||||
All requests return things on this form (results field is added if successful.)
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
status: STATUSCODE,
|
|
||||||
error: MESSAGE,
|
|
||||||
success: IF_SUCCESSFULL,
|
|
||||||
results: [RESULTS]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Add song
|
|
||||||
|
|
||||||
```
|
|
||||||
POST /api/list/:channel_name/:video_id
|
|
||||||
{
|
|
||||||
"title": TITLE,
|
|
||||||
"duration": END_TIME - START_TIME,
|
|
||||||
"end_time": END_TIME,
|
|
||||||
"start_time": START_TIME,
|
|
||||||
"adminpass": PASSWORD, (leave this blank if there is no password/you don't know the password)
|
|
||||||
"userpass": USER_PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication (but will return a song object, with the type == "suggested", and the song will show up in the suggested tab for channel-admins)
|
|
||||||
Returns 409 if the song exists
|
|
||||||
Returns 429 if you're doing too much of this request, with a Retry-After int value in the header.
|
|
||||||
Returns 200 and the added song object if successful
|
|
||||||
```
|
|
||||||
|
|
||||||
Delete song
|
|
||||||
```
|
|
||||||
DELETE /api/list/:channel_name/:video_id
|
|
||||||
{
|
|
||||||
"adminpass": PASSWORD,
|
|
||||||
"userpass": USER_PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the song doesnt exist or is the currently playing song
|
|
||||||
Returns 429 if you're doing too much of this request, with a Retry-After int value in the header.
|
|
||||||
Returns 200 if successful
|
|
||||||
```
|
|
||||||
|
|
||||||
Vote on song
|
|
||||||
```
|
|
||||||
PUT /api/list/:channel_name/:video_id
|
|
||||||
{
|
|
||||||
"adminpass": PASSWORD,
|
|
||||||
"userpass": USER_PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the song doesnt exist
|
|
||||||
Returns 409 if you've already voted on that song
|
|
||||||
Returns 429 if you're doing too much of this request, with a Retry-After int value in the header.
|
|
||||||
Returns 200 and the added song object if successful
|
|
||||||
```
|
|
||||||
|
|
||||||
Change channel configurations
|
|
||||||
```
|
|
||||||
PUT /api/conf/:channel_name
|
|
||||||
{
|
|
||||||
"userpass": USER_PASSWORD,
|
|
||||||
"adminpass": PASSWORD,
|
|
||||||
"vote": BOOLEAN,
|
|
||||||
"addsongs": BOOLEAN,
|
|
||||||
"longsongs": BOOLEAN,
|
|
||||||
"frontpage": BOOLEAN (if you want to set userpassword, this MUST be false for it to work),
|
|
||||||
"allvideos": BOOLEAN,
|
|
||||||
"removeplay": BOOLEAN,
|
|
||||||
"skip": BOOLEAN,
|
|
||||||
"shuffle": BOOLEAN,
|
|
||||||
"userpass_changed": BOOLEAN (this must be true if you want to keep the userpassword you're sending)
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the list doesn't exist
|
|
||||||
Returns 429 if you're doing too much of this request, with a Retry-After int value in the header.
|
|
||||||
Returns 200 and the newly added configuration if successful
|
|
||||||
```
|
|
||||||
|
|
||||||
Get channelsettings
|
|
||||||
```
|
|
||||||
GET /api/conf/:channel_name/
|
|
||||||
|
|
||||||
Returns 403 for bad authentication (if you get this, try POST with userpassword attached)
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the settings-object
|
|
||||||
```
|
|
||||||
|
|
||||||
Get channelsettings (protected)
|
|
||||||
```
|
|
||||||
POST /api/conf/:channel_name/
|
|
||||||
{
|
|
||||||
"userpass": USERPASS
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the settings-object
|
|
||||||
```
|
|
||||||
|
|
||||||
Get song in channel
|
|
||||||
```
|
|
||||||
GET /api/list/:channel_name/
|
|
||||||
|
|
||||||
Returns 403 for bad authentication (if you get this, the channel is protected, try getting the full channel with POST, and search through the object)
|
|
||||||
Returns 404 if the song doesn't exist
|
|
||||||
Returns 200 and the song
|
|
||||||
```
|
|
||||||
|
|
||||||
Get song in channel (protected)
|
|
||||||
```
|
|
||||||
// Important fetch_song is present, or else the request will try to add a song to the channel
|
|
||||||
POST /api/list/:channel_name/
|
|
||||||
{
|
|
||||||
"fetch_song": ANYTHING_HERE,
|
|
||||||
"userpass": USERPASS
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the song doesn't exist
|
|
||||||
Returns 200 and the song
|
|
||||||
```
|
|
||||||
|
|
||||||
Get channelsettings
|
|
||||||
```
|
|
||||||
GET /api/conf/:channel_name/
|
|
||||||
|
|
||||||
Returns 403 for bad authentication (if you get this, try POST with userpassword attached)
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the objects in the channel
|
|
||||||
```
|
|
||||||
|
|
||||||
Get channelsettings (protected)
|
|
||||||
```
|
|
||||||
POST /api/conf/:channel_name/
|
|
||||||
{
|
|
||||||
"userpass": USERPASS
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the objects in the channel
|
|
||||||
```
|
|
||||||
|
|
||||||
Get now playing song
|
|
||||||
```
|
|
||||||
GET /api/list/:channel_name/__np__
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication (if you get this, try POST with userpassword attached)
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the now playing object
|
|
||||||
```
|
|
||||||
|
|
||||||
Get now playing song (protected)
|
|
||||||
```
|
|
||||||
POST /api/list/:channel_name/__np__
|
|
||||||
{
|
|
||||||
"userpass": USERPASS
|
|
||||||
}
|
|
||||||
|
|
||||||
Returns 400 for bad request
|
|
||||||
Returns 403 for bad authentication (if you get this, try POST with userpassword attached)
|
|
||||||
Returns 404 if the channel doesn't exist
|
|
||||||
Returns 200 and the now playing object
|
|
||||||
```
|
|
||||||
|
|
||||||
Get all lists
|
|
||||||
```
|
|
||||||
GET /api/frontpages
|
|
||||||
|
|
||||||
Returns 200 and the frontpage-lists
|
|
||||||
```
|
|
||||||
|
|
||||||
Still to come: SKIP and SHUFFLE RESTApi calls..
|
|
||||||
|
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
### To server
|
[Events sent form the server/to the server info](EVENTS.md)
|
||||||
```
|
|
||||||
// Tells the server the song is over
|
|
||||||
'end', {
|
|
||||||
id: video_id,
|
|
||||||
channel: channel_name,
|
|
||||||
pass: channel_pass
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asks server where in the song it should be
|
|
||||||
'pos', {
|
|
||||||
channel: channel_name,
|
|
||||||
pass: channel_pass
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tells the server the client wants the list
|
|
||||||
'list', {
|
|
||||||
channel: channel_name,
|
|
||||||
pass: channel_pass,
|
|
||||||
version: system_version (can be checked in VERSION.js)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends info about a song the client wants to add
|
|
||||||
'add', {
|
|
||||||
id: VIDEO_ID,
|
|
||||||
title: VIDEO_TITLE,
|
|
||||||
adminpass: AES-CBC-Pkcs7 with Base64 IV(PASSWORD),
|
|
||||||
duration: VIDEO_DURATION,
|
|
||||||
list: channel_name,
|
|
||||||
playlist: true_if_importing_playlist,
|
|
||||||
num: current_number_of_sending_songs,
|
|
||||||
total: total_number_of_sending_songs,
|
|
||||||
pass: channel_pass
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tells the server to disconnect the user from the current channel, is used for remote controlling on the host side
|
|
||||||
'change_channel', {
|
|
||||||
channel: channel_name
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends chat text to all chat
|
|
||||||
'all,chat', {
|
|
||||||
channel: channel_name,
|
|
||||||
data: input
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends chat text to channelchat
|
|
||||||
'chat',{
|
|
||||||
channel: channel_name,
|
|
||||||
data: input,
|
|
||||||
pass: channel_pass
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends info about song the user wants to vote on. If VOTE_TYPE is del, its deleting the song, if its pos, its just voting
|
|
||||||
'vote', {
|
|
||||||
channel: CHANNEL_NAME,
|
|
||||||
id: VIDEO_ID,
|
|
||||||
type: VOTE_TYPE,
|
|
||||||
adminpass: AES-CBC-Pkcs7 with Base64 IV(PASSWORD)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends shuffle to the server (Only works every 5 seconds per list)
|
|
||||||
'shuffle', {
|
|
||||||
adminpass: AES-CBC-Pkcs7 with Base64 IV(PASSWORD),
|
|
||||||
channel: CHANNELNAME,
|
|
||||||
pass: USER_PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends skip message to server
|
|
||||||
'skip', {
|
|
||||||
pass: AES-CBC-Pkcs7 with Base64 IV(PASSWORD),
|
|
||||||
id:video_id,
|
|
||||||
channel: chan,
|
|
||||||
userpass: channel_pass
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends password for instant log in to server
|
|
||||||
'password', {
|
|
||||||
password: PASSWORD,
|
|
||||||
channel: CHANNEL_NAME,
|
|
||||||
oldpass: old_pass_if_changing_password
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message to the host channel for play
|
|
||||||
'id', {
|
|
||||||
id: CHANNEL_ID,
|
|
||||||
type: "play",
|
|
||||||
value: "mock"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message to the host channel for pause
|
|
||||||
'id', {
|
|
||||||
id: CHANNEL_ID,
|
|
||||||
type: "pause",
|
|
||||||
value: "mock"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message to the host channel for skip
|
|
||||||
'id', {
|
|
||||||
id: CHANNEL_ID,
|
|
||||||
type: "skip",
|
|
||||||
value: "mock"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message to the host channel to change volume
|
|
||||||
'id', {
|
|
||||||
id: CHANNEL_ID,
|
|
||||||
type: "volume",
|
|
||||||
value: VALUE
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends message to the host channel to change channel
|
|
||||||
'id', {
|
|
||||||
id: CHANNEL_ID,
|
|
||||||
type: "channel",
|
|
||||||
value: NEW_CHANNEL_NAME
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends a video that triggered an error
|
|
||||||
'error_video', {
|
|
||||||
channel: CHANNE_NAME,
|
|
||||||
id: VIDEO_ID,
|
|
||||||
title: VIDEO_TITLE
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### From server
|
|
||||||
```
|
|
||||||
// Receives a string from server for what type of toast to be triggered
|
|
||||||
'toast', STRING
|
|
||||||
|
|
||||||
// Receives a boolean if the password was correct
|
|
||||||
'pw', BOOLEAN
|
|
||||||
|
|
||||||
// Receives configuration array from server
|
|
||||||
'conf', [ARRAY]
|
|
||||||
|
|
||||||
// Receives chat message from allchat
|
|
||||||
'chat.all', {
|
|
||||||
from: name,
|
|
||||||
msg: message,
|
|
||||||
channel: channel,
|
|
||||||
icon: icon_src
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives chat-history for all and for current channel
|
|
||||||
'chat_history', {
|
|
||||||
all: BOOLEAN (if true, it is for all-chat),
|
|
||||||
data: CHAT_HISTORY
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives chat message from channelchat
|
|
||||||
'chat', {
|
|
||||||
from: name,
|
|
||||||
msg: message,
|
|
||||||
icon: icon_src
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives the ID of the current client, used for remote listening
|
|
||||||
'id', STRING
|
|
||||||
|
|
||||||
// Receives the messages sent on CHANNEL_ID above
|
|
||||||
id, {
|
|
||||||
type: STRING,
|
|
||||||
value: VALUE
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives updates from channel. type is one of the following: list, added, deleted, vote, song_change, changed_values (see further down for better explanation here)
|
|
||||||
'channel', {
|
|
||||||
type: TYPE,
|
|
||||||
value: value,
|
|
||||||
time: time_of_occurence
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives message from the server that its ready to send the playlist and info
|
|
||||||
'get_list'
|
|
||||||
|
|
||||||
// Receives array of now playing song. Is triggered on song-change
|
|
||||||
'np', {
|
|
||||||
np: NOW_PLAYING,
|
|
||||||
conf: CONFIGURATION,
|
|
||||||
time: SERVER_TIME
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receives number of viewers on the current channel
|
|
||||||
'viewers', VALUE
|
|
||||||
|
|
||||||
// Receives a newly updated video, that was checked for errors (song_generated contains .id which is the current id of the video, and a .new_id for the new video to change the video to)
|
|
||||||
'channel', {
|
|
||||||
type: "changed_values",
|
|
||||||
value: song_generated
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -29,10 +29,24 @@ function chat(msg, guid, offline, socket) {
|
|||||||
!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('pass') ||
|
!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('pass') ||
|
||||||
typeof(msg.data) != "string" || typeof(msg.channel) != "string" ||
|
typeof(msg.data) != "string" || typeof(msg.channel) != "string" ||
|
||||||
typeof(msg.pass) != "string") {
|
typeof(msg.pass) != "string") {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
data: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("data") ? typeof(msg.data) : undefined,
|
||||||
|
},
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coll = msg.channel;
|
var coll = msg.channel.toLowerCase();
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
||||||
var data = msg.data;
|
var data = msg.data;
|
||||||
@@ -64,10 +78,20 @@ function all_chat(msg, guid, offline, socket) {
|
|||||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") ||
|
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") ||
|
||||||
!msg.hasOwnProperty("data") || typeof(msg.data) != "string" ||
|
!msg.hasOwnProperty("data") || typeof(msg.data) != "string" ||
|
||||||
typeof(msg.channel) != "string") {
|
typeof(msg.channel) != "string") {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
data: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("data") ? typeof(msg.data) : undefined,
|
||||||
|
},
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coll = msg.channel;
|
var coll = msg.channel.toLowerCase();
|
||||||
var data = msg.data;
|
var data = msg.data;
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
function frontpage_lists(msg, socket) {
|
function frontpage_lists(msg, socket) {
|
||||||
if(msg == undefined || !msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
if(msg == undefined || !msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
version: {
|
||||||
|
expected: VERSION,
|
||||||
|
got: msg.hasOwnProperty("version") ? msg.version : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ module.exports = function() {
|
|||||||
guid = msg.guid;
|
guid = msg.guid;
|
||||||
socketid = msg.socket_id;
|
socketid = msg.socket_id;
|
||||||
socket.zoff_id = socketid;
|
socket.zoff_id = socketid;
|
||||||
coll = msg.channel;
|
coll = msg.channel.toLowerCase();
|
||||||
in_list = true;
|
in_list = true;
|
||||||
chromecast_object = true;
|
chromecast_object = true;
|
||||||
socket.join(coll);
|
socket.join(coll);
|
||||||
@@ -108,7 +108,13 @@ module.exports = function() {
|
|||||||
|
|
||||||
socket.on("removename", function(msg) {
|
socket.on("removename", function(msg) {
|
||||||
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
|
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Chat.removename(guid, msg.channel);
|
Chat.removename(guid, msg.channel);
|
||||||
@@ -117,7 +123,17 @@ module.exports = function() {
|
|||||||
socket.on("offline", function(msg){
|
socket.on("offline", function(msg){
|
||||||
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
||||||
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
status: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: msg.hasOwnProperty("status") ? typeof(msg.status) : undefined,
|
||||||
|
},
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var status = msg.status;
|
var status = msg.status;
|
||||||
@@ -164,7 +180,21 @@ module.exports = function() {
|
|||||||
socket.on('get_history', function(msg) {
|
socket.on('get_history', function(msg) {
|
||||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
||||||
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
all: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: msg.hasOwnProperty("all") ? typeof(msg.all) : undefined,
|
||||||
|
},
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Chat.get_history(msg.channel, msg.all, socket);
|
Chat.get_history(msg.channel, msg.all, socket);
|
||||||
@@ -219,7 +249,7 @@ module.exports = function() {
|
|||||||
{
|
{
|
||||||
if(coll === undefined) {
|
if(coll === undefined) {
|
||||||
try {
|
try {
|
||||||
coll = obj.channel;
|
coll = obj.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -252,7 +282,7 @@ module.exports = function() {
|
|||||||
socket.on('delete_all', function(msg) {
|
socket.on('delete_all', function(msg) {
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = msg.channel;
|
coll = msg.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -270,7 +300,7 @@ module.exports = function() {
|
|||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = msg.channel;
|
coll = msg.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -302,7 +332,7 @@ module.exports = function() {
|
|||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = msg.channel;
|
coll = msg.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -319,7 +349,7 @@ module.exports = function() {
|
|||||||
{
|
{
|
||||||
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
||||||
try {
|
try {
|
||||||
coll = obj.channel;
|
coll = obj.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -364,7 +394,7 @@ module.exports = function() {
|
|||||||
(obj.hasOwnProperty("pass") && typeof(obj.pass) != "string"))
|
(obj.hasOwnProperty("pass") && typeof(obj.pass) != "string"))
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = obj.channel;
|
coll = obj.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -375,8 +405,20 @@ module.exports = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
if(coll == "" || coll == undefined || coll == null ||
|
||||||
socket.emit("update_required");
|
!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string" ||
|
||||||
|
obj.hasOwnProperty("pass") || typeof(obj.pass) != "string") {
|
||||||
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,18 +20,29 @@ function now_playing(list, fn, socket) {
|
|||||||
function list(msg, guid, coll, offline, socket) {
|
function list(msg, guid, coll, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
|
|
||||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
|
if(typeof(msg) === 'object' && msg !== undefined && msg !== null)
|
||||||
{
|
{
|
||||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined ||
|
if(!msg.hasOwnProperty('version') || !msg.hasOwnProperty("channel") || !msg.hasOwnProperty("pass") ||
|
||||||
|
msg.version != VERSION || msg.version == undefined ||
|
||||||
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
return;
|
channel: {
|
||||||
}
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
},
|
||||||
socket.emit("update_required");
|
version: {
|
||||||
|
expected: VERSION,
|
||||||
|
got: msg.version,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
coll = msg.channel.toLowerCase();
|
||||||
var pass = Functions.decrypt_string(socketid, msg.pass);
|
var pass = Functions.decrypt_string(socketid, msg.pass);
|
||||||
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
||||||
if(frontpage_lists.length == 1)
|
if(frontpage_lists.length == 1)
|
||||||
@@ -70,7 +81,13 @@ function list(msg, guid, coll, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(msg)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +96,10 @@ function skip(list, guid, coll, offline, socket) {
|
|||||||
|
|
||||||
if(list !== undefined && list !== null && list !== "")
|
if(list !== undefined && list !== null && list !== "")
|
||||||
{
|
{
|
||||||
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel;
|
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = list.channel;
|
coll = list.channel.toLowerCase();
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
@@ -92,9 +109,29 @@ function skip(list, guid, coll, offline, socket) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
if(!list.hasOwnProperty("pass") || !list.hasOwnProperty("userpass") ||
|
||||||
|
!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") ||
|
||||||
|
typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
||||||
typeof(list.channel) != "string" || typeof(list.userpass) != "string") {
|
typeof(list.channel) != "string" || typeof(list.userpass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: list.hasOwnProperty("channel") ? typeof(list.channel) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: list.hasOwnProperty("pass") ? typeof(list.pass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: list.hasOwnProperty("userpass") ? typeof(list.userpass) : undefined,
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
expected: "string",
|
||||||
|
got: list.hasOwnProperty("id") ? typeof(list.id) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
@@ -165,7 +202,13 @@ function skip(list, guid, coll, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(list),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,9 +478,24 @@ function end(obj, coll, guid, offline, socket) {
|
|||||||
|
|
||||||
if(id !== undefined && id !== null && id !== "") {
|
if(id !== undefined && id !== null && id !== "") {
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null || typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
if(!obj.hasOwnProperty("id") || !obj.hasOwnProperty("channel") || !obj.hasOwnProperty("pass") ||
|
||||||
|
typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||||
typeof(obj.pass) != "string") {
|
typeof(obj.pass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined,
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
expected: "string",
|
||||||
|
got: obj.hasOwnProperty("id") ? typeof(obj.id) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +528,13 @@ function end(obj, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(obj)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,19 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
|
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null || !arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
if(coll == "" || coll == undefined || coll == null ||
|
||||||
socket.emit("update_required");
|
!arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
||||||
|
var result = {
|
||||||
|
start: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +45,49 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
typeof(arr.playlist) != "boolean" || typeof(arr.num) != "number" ||
|
typeof(arr.playlist) != "boolean" || typeof(arr.num) != "number" ||
|
||||||
typeof(arr.total) != "number" || typeof(arr.pass) != "string" ||
|
typeof(arr.total) != "number" || typeof(arr.pass) != "string" ||
|
||||||
typeof(arr.adminpass) != "string") {
|
typeof(arr.adminpass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
start: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
expected: "string",
|
||||||
|
got: arr.hasOwnProperty("title") ? typeof(arr.title) : undefined
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
expected: "string",
|
||||||
|
got: arr.hasOwnProperty("list") ? typeof(arr.list) : undefined
|
||||||
|
},
|
||||||
|
duration: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined
|
||||||
|
},
|
||||||
|
playlist: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: arr.hasOwnProperty("playlist") ? typeof(arr.playlist) : undefined
|
||||||
|
},
|
||||||
|
num: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("num") ? typeof(arr.num) : undefined
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("total") ? typeof(arr.total) : undefined
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: arr.hasOwnProperty("pass") ? typeof(arr.pass) : undefined
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: arr.hasOwnProperty("adminpass") ? typeof(arr.adminpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +229,17 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
arr: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(arr)
|
||||||
|
},
|
||||||
|
duration: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,19 +247,39 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
|||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) {
|
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("id") ||
|
||||||
socket.emit("update_required");
|
!msg.hasOwnProperty("type") || !msg.hasOwnProperty("adminpass") ||
|
||||||
|
!msg.hasOwnProperty("pass") || typeof(msg.pass) != "string" ||
|
||||||
|
typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
||||||
|
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string") {
|
||||||
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("id") ? typeof(msg.id) : undefined,
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("type") ? typeof(msg.type) : undefined,
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "adminpass",
|
||||||
|
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
coll = msg.channel.toLowerCase();;
|
||||||
|
|
||||||
if(typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
db.collection(coll + "_settings").find({id: "config"}, function(err, docs){
|
||||||
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string" ||
|
|
||||||
typeof(msg.pass) != "string") {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
@@ -218,24 +301,41 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(msg)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffle(msg, coll, guid, offline, socket) {
|
function shuffle(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null)
|
|
||||||
{
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof(msg.adminpass) != "string" || typeof(msg.channel) != "string" ||
|
|
||||||
typeof(msg.pass) != "string") {
|
if(!msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("channel") ||
|
||||||
socket.emit("update_required");
|
!msg.hasOwnProperty("pass") || typeof(msg.adminpass) != "string" ||
|
||||||
|
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
||||||
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "adminpass",
|
||||||
|
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
coll = msg.channel.toLowerCase();
|
||||||
|
|
||||||
db.collection("timeout_api").find({
|
db.collection("timeout_api").find({
|
||||||
type: "shuffle",
|
type: "shuffle",
|
||||||
@@ -294,8 +394,6 @@ function shuffle(msg, coll, guid, offline, socket) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}else
|
|
||||||
socket.emit("toast", "wrongpass");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function del(params, socket, socketid) {
|
function del(params, socket, socketid) {
|
||||||
@@ -328,15 +426,30 @@ function del(params, socket, socketid) {
|
|||||||
|
|
||||||
function delete_all(msg, coll, guid, offline, socket) {
|
function delete_all(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
|
if(typeof(msg) == 'object' ) {
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
if(!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('adminpass') ||
|
||||||
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
!msg.hasOwnProperty('pass') || typeof(msg.channel) != "string" ||
|
||||||
|
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||||
if(typeof(msg.channel) != "string" || typeof(msg.adminpass) != "string" ||
|
var result = {
|
||||||
typeof(msg.pass) != "string") {
|
channel: {
|
||||||
socket.emit("update_required");
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "adminpass",
|
||||||
|
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||||
|
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
||||||
db.collection(coll + "_settings").find(function(err, conf) {
|
db.collection(coll + "_settings").find(function(err, conf) {
|
||||||
if(conf.length == 1 && conf) {
|
if(conf.length == 1 && conf) {
|
||||||
conf = conf[0];
|
conf = conf[0];
|
||||||
@@ -352,7 +465,13 @@ function delete_all(msg, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(msg)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,17 @@ function password(inp, coll, guid, offline, socket) {
|
|||||||
{
|
{
|
||||||
if(!inp.hasOwnProperty("password") || !inp.hasOwnProperty("channel") ||
|
if(!inp.hasOwnProperty("password") || !inp.hasOwnProperty("channel") ||
|
||||||
typeof(inp.password) != "string" || typeof(inp.channel) != "string") {
|
typeof(inp.password) != "string" || typeof(inp.channel) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: inp.hasOwnProperty("channel") ? typeof(iinp.channel) : undefined,
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
expected: "password",
|
||||||
|
got: inp.hasOwnProperty("password") ? typeof(inp.password) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pw = inp.password;
|
pw = inp.password;
|
||||||
@@ -19,11 +29,6 @@ function password(inp, coll, guid, offline, socket) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uncrypted = pw;
|
uncrypted = pw;
|
||||||
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
@@ -51,22 +56,18 @@ function password(inp, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
inp: {
|
||||||
|
expected: "string",
|
||||||
|
got: typeof(inpt)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function conf_function(params, coll, guid, offline, socket) {
|
function conf_function(params, coll, guid, offline, socket) {
|
||||||
if(params !== undefined && params !== null && params !== "" &&
|
if(params !== undefined && params !== null && params !== "")
|
||||||
params.hasOwnProperty('voting') &&
|
|
||||||
params.hasOwnProperty('addsongs') &&
|
|
||||||
params.hasOwnProperty('longsongs') &&
|
|
||||||
params.hasOwnProperty('frontpage') &&
|
|
||||||
params.hasOwnProperty('allvideos') &&
|
|
||||||
params.hasOwnProperty('removeplay') &&
|
|
||||||
params.hasOwnProperty('adminpass') &&
|
|
||||||
params.hasOwnProperty('skipping') &&
|
|
||||||
params.hasOwnProperty('shuffling') &&
|
|
||||||
params.hasOwnProperty('channel'))
|
|
||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
@@ -88,6 +89,59 @@ function conf_function(params, coll, guid, offline, socket) {
|
|||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
|
|
||||||
|
if(!params.hasOwnProperty('voting') || !params.hasOwnProperty('addsongs') ||
|
||||||
|
!params.hasOwnProperty('longsongs') || !params.hasOwnProperty('frontpage') ||
|
||||||
|
!params.hasOwnProperty('allvideos') || !params.hasOwnProperty('removeplay') ||
|
||||||
|
!params.hasOwnProperty('adminpass') || !params.hasOwnProperty('skipping') ||
|
||||||
|
!params.hasOwnProperty('shuffling') || !params.hasOwnProperty('channel') ||
|
||||||
|
typeof(params.userpass) != "string" || typeof(params.adminpass) != "string" ||
|
||||||
|
typeof(params.voting) != "boolean" || typeof(params.addsongs) != "boolean" ||
|
||||||
|
typeof(params.longsongs) != "boolean" || typeof(params.frontpage) != "boolean" ||
|
||||||
|
typeof(params.allvideos) != "boolean" || typeof(params.removeplay) != "boolean" ||
|
||||||
|
typeof(params.skipping) != "boolean" || typeof(params.shuffling) != "boolean" ||
|
||||||
|
typeof(params.userpass_changed) != "boolean") {
|
||||||
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: params.hasOwnProperty("adminpass") ? typeof(params.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: params.hasOwnProperty("userpass") ? typeof(params.userpass) : undefined,
|
||||||
|
},
|
||||||
|
vote: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("vote") ? typeof(params.vote) : undefined,
|
||||||
|
},
|
||||||
|
addsongs: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("addsongs") ? typeof(params.addsongs) : undefined,
|
||||||
|
},
|
||||||
|
longsongs: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("longsongs") ? typeof(params.longsongs) : undefined,
|
||||||
|
},
|
||||||
|
frontpage: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("frontpage") ? typeof(params.frontpage) : undefined,
|
||||||
|
},
|
||||||
|
skipping: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("skipping") ? typeof(params.skipping) : undefined,
|
||||||
|
},
|
||||||
|
shuffling: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("shuffling") ? typeof(params.shuffling) : undefined,
|
||||||
|
},
|
||||||
|
userpass_changed: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: params.hasOwnProperty("userpass_changed") ? typeof(params.userpass_changed) : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var voting = params.voting;
|
var voting = params.voting;
|
||||||
var addsongs = params.addsongs;
|
var addsongs = params.addsongs;
|
||||||
var longsongs = params.longsongs;
|
var longsongs = params.longsongs;
|
||||||
@@ -98,15 +152,6 @@ function conf_function(params, coll, guid, offline, socket) {
|
|||||||
var skipping = params.skipping;
|
var skipping = params.skipping;
|
||||||
var shuffling = params.shuffling;
|
var shuffling = params.shuffling;
|
||||||
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
||||||
if(typeof(userpass) != "string" || typeof(adminpass) != "string" ||
|
|
||||||
typeof(voting) != "boolean" || typeof(addsongs) != "boolean" ||
|
|
||||||
typeof(longsongs) != "boolean" || typeof(frontpage) != "boolean" ||
|
|
||||||
typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" ||
|
|
||||||
typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" ||
|
|
||||||
typeof(params.userpass_changed) != "boolean") {
|
|
||||||
socket.emit("toast", "wrongpass");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
||||||
userpass = "";
|
userpass = "";
|
||||||
@@ -162,7 +207,13 @@ function conf_function(params, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('update_required');
|
var result = {
|
||||||
|
params: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(params),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
socket.emit('update_required', result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,17 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
|||||||
function check_error_video(msg, channel) {
|
function check_error_video(msg, channel) {
|
||||||
if(!msg.hasOwnProperty("id") || !msg.hasOwnProperty("title") ||
|
if(!msg.hasOwnProperty("id") || !msg.hasOwnProperty("title") ||
|
||||||
typeof(msg.id) != "string" || typeof(msg.title) != "string") {
|
typeof(msg.id) != "string" || typeof(msg.title) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
id: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("id") ? typeof(msg.id) : undefined,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("title") ? typeof(msg.title) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,25 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
|||||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
||||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
thumbnail: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("thumbnail") ? typeof(msg.thumbnail) : undefined,
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
||||||
@@ -30,7 +48,25 @@ function description(msg, coll, guid, offline, socket) {
|
|||||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
||||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||||
socket.emit("update_required");
|
var result = {
|
||||||
|
channel: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("description") ? typeof(msg.description) : undefined,
|
||||||
|
},
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: msg.hasOwnProperty("adminpass") ? typeof(msg.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit("update_required", result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var channel = msg.channel.toLowerCase();
|
var channel = msg.channel.toLowerCase();
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ var Channel = {
|
|||||||
if(socket === undefined || Helper.mobilecheck()){
|
if(socket === undefined || Helper.mobilecheck()){
|
||||||
no_socket = false;
|
no_socket = false;
|
||||||
socket = io.connect(''+add+':8080', connection_options);
|
socket = io.connect(''+add+':8080', connection_options);
|
||||||
socket.on('update_required', function() {
|
socket.on('update_required', function(msg) {
|
||||||
|
if(window.location.hostname == "localhost") {
|
||||||
|
console.log(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,19 @@ router.route('/api/list/:channel_name/:video_id').delete(function(req, res) {
|
|||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
||||||
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id')) {
|
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("adminpass") ? typeof(req.body.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var token = "";
|
var token = "";
|
||||||
@@ -138,7 +150,19 @@ router.route('/api/list/:channel_name/:video_id').delete(function(req, res) {
|
|||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("adminpass") ? typeof(req.body.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,20 +226,20 @@ router.route('/api/conf/:channel_name').put(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
|
try {
|
||||||
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
||||||
!req.params.hasOwnProperty('channel_name') || !req.body.hasOwnProperty('vote') ||
|
!req.params.hasOwnProperty('channel_name') || !req.body.hasOwnProperty('vote') ||
|
||||||
!req.body.hasOwnProperty('addsongs') || !req.body.hasOwnProperty('longsongs') ||
|
!req.body.hasOwnProperty('addsongs') || !req.body.hasOwnProperty('longsongs') ||
|
||||||
!req.body.hasOwnProperty('frontpage') || !req.body.hasOwnProperty('allvideos') ||
|
!req.body.hasOwnProperty('frontpage') || !req.body.hasOwnProperty('allvideos') ||
|
||||||
!req.body.hasOwnProperty('skip') || !req.body.hasOwnProperty('shuffle') ||
|
!req.body.hasOwnProperty('skip') || !req.body.hasOwnProperty('shuffle') ||
|
||||||
!req.body.hasOwnProperty('userpass_changed')) {
|
!req.body.hasOwnProperty('userpass_changed')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var token = "";
|
var token = "";
|
||||||
if(req.body.hasOwnProperty("token")) {
|
if(req.body.hasOwnProperty("token")) {
|
||||||
token = req.body.token;
|
token = req.body.token;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
|
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
|
||||||
@@ -240,7 +264,47 @@ router.route('/api/conf/:channel_name').put(function(req, res) {
|
|||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("adminpass") ? typeof(req.body.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined,
|
||||||
|
},
|
||||||
|
vote: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("vote") ? typeof(req.body.vote) : undefined,
|
||||||
|
},
|
||||||
|
addsongs: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("addsongs") ? typeof(req.body.addsongs) : undefined,
|
||||||
|
},
|
||||||
|
longsongs: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("longsongs") ? typeof(req.body.longsongs) : undefined,
|
||||||
|
},
|
||||||
|
frontpage: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("frontpage") ? typeof(req.body.frontpage) : undefined,
|
||||||
|
},
|
||||||
|
skip: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("skip") ? typeof(req.body.skip) : undefined,
|
||||||
|
},
|
||||||
|
shuffle: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("shuffle") ? typeof(req.body.shuffle) : undefined,
|
||||||
|
},
|
||||||
|
userpass_changed: {
|
||||||
|
expected: "boolean",
|
||||||
|
got: req.body.hasOwnProperty("userpass_changed") ? typeof(req.body.userpass_changed) : undefined,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,16 +386,15 @@ router.route('/api/list/:channel_name/:video_id').put(function(req,res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
|
try {
|
||||||
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
if(!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
||||||
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id')) {
|
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var token = "";
|
var token = "";
|
||||||
if(req.body.hasOwnProperty("token")) {
|
if(req.body.hasOwnProperty("token")) {
|
||||||
token = req.body.token;
|
token = req.body.token;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
|
var adminpass = req.body.adminpass == "" ? "" : Functions.hash_pass(crypto.createHash('sha256').update(req.body.adminpass, 'utf8').digest("hex"));
|
||||||
@@ -343,7 +406,19 @@ router.route('/api/list/:channel_name/:video_id').put(function(req,res) {
|
|||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("adminpass") ? typeof(req.body.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,10 +477,9 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
|
try {
|
||||||
if(!req.body.hasOwnProperty('userpass')) {
|
if(!req.body.hasOwnProperty('userpass')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
@@ -418,7 +492,18 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
|
|||||||
token = req.body.token;
|
token = req.body.token;
|
||||||
}
|
}
|
||||||
if(typeof(userpass) != "string") {
|
if(typeof(userpass) != "string") {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
var result = {
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
token_db.collection("api_token").find({token: token}, function(err, token_docs) {
|
token_db.collection("api_token").find({token: token}, function(err, token_docs) {
|
||||||
@@ -474,14 +559,14 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
if(req.body.hasOwnProperty("token")) {
|
if(req.body.hasOwnProperty("token")) {
|
||||||
token = req.body.token;
|
token = req.body.token;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if(!fetch_only && (!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
if(!fetch_only && (!req.body.hasOwnProperty('adminpass') || !req.body.hasOwnProperty('userpass') ||
|
||||||
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id') ||
|
!req.params.hasOwnProperty('channel_name') || !req.params.hasOwnProperty('video_id') ||
|
||||||
!req.body.hasOwnProperty('duration') || !req.body.hasOwnProperty('start_time') ||
|
!req.body.hasOwnProperty('duration') || !req.body.hasOwnProperty('start_time') ||
|
||||||
!req.body.hasOwnProperty('end_time') || !req.body.hasOwnProperty('title'))) {
|
!req.body.hasOwnProperty('end_time') || !req.body.hasOwnProperty('title'))) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
|
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("hex");
|
||||||
@@ -496,12 +581,40 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
if(duration != end_time - start_time) duration = end_time - start_time;
|
if(duration != end_time - start_time) duration = end_time - start_time;
|
||||||
var title = req.body.title;
|
var title = req.body.title;
|
||||||
if(typeof(userpass) != "string" || typeof(adminpass) != "string" ||
|
if(typeof(userpass) != "string" || typeof(adminpass) != "string" ||
|
||||||
typeof(title) != "string") {
|
typeof(title) != "string" || isNaN(duration) || isNaN(start_time) || isNaN(end_time)) {
|
||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
var result = {
|
||||||
|
adminpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("adminpass") ? typeof(req.body.adminpass) : undefined,
|
||||||
|
},
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("title") ? typeof(req.body.title) : undefined
|
||||||
|
},
|
||||||
|
start_time: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: !req.body.hasOwnProperty("start_time") ? undefined : isNaN(req.body.start_time) ? "uncastable string" : typeof(req.body.start_time)
|
||||||
|
},
|
||||||
|
end_time: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: !req.body.hasOwnProperty("end_time") ? undefined : isNaN(req.body.end_time) ? "uncastable string" : typeof(req.body.end_time)
|
||||||
|
},
|
||||||
|
duration: {
|
||||||
|
expected: "number or string that can be cast to int",
|
||||||
|
got: !req.body.hasOwnProperty("duration") ? undefined : isNaN(req.body.duration) ? "uncastable string" : typeof(req.body.duration)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,9 +806,9 @@ router.route('/api/conf/:channel_name').post(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
|
try {
|
||||||
if(!req.body.hasOwnProperty('userpass')) {
|
if(!req.body.hasOwnProperty('userpass')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format"
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var token = "";
|
var token = "";
|
||||||
if(req.body.hasOwnProperty("token")) {
|
if(req.body.hasOwnProperty("token")) {
|
||||||
@@ -708,7 +821,18 @@ router.route('/api/conf/:channel_name').post(function(req, res) {
|
|||||||
var userpass = req.body.userpass;
|
var userpass = req.body.userpass;
|
||||||
|
|
||||||
if(typeof(userpass) != "string") {
|
if(typeof(userpass) != "string") {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
var result = {
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,9 +917,9 @@ router.route('/api/list/:channel_name').post(function(req, res) {
|
|||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
|
try {
|
||||||
if(!req.body.hasOwnProperty('userpass')) {
|
if(!req.body.hasOwnProperty('userpass')) {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var token = "";
|
var token = "";
|
||||||
@@ -809,7 +933,18 @@ router.route('/api/list/:channel_name').post(function(req, res) {
|
|||||||
var userpass = req.body.userpass;
|
var userpass = req.body.userpass;
|
||||||
|
|
||||||
if(typeof(userpass) != "string") {
|
if(typeof(userpass) != "string") {
|
||||||
res.status(400).send(JSON.stringify(error.formatting));
|
throw "Wrong format";
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
var result = {
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results.push(result);
|
||||||
|
res.status(400).send(JSON.stringify(to_send));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user