Skip to content

Commit

Permalink
synced with up to date code
Browse files Browse the repository at this point in the history
  • Loading branch information
jo32pilot committed Dec 20, 2019
1 parent 4880825 commit 7f00bc6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions backend/SQLQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function addStreamerTable(channelId){
});

if(!toReturn){
connection.relase();
connection.release();
}

});
Expand Down Expand Up @@ -642,7 +642,7 @@ function updateGraphTable(channelId, times){
return;
}

pool.query("ALTER TABLE ? ADD \`?\` INT NOT NULL DEFAULT 0;",
connection.query("ALTER TABLE ? ADD \`?\` INT NOT NULL DEFAULT 0;",
[channelId, today], function(error){

if(toReturn || _assertError(error, connection)){
Expand All @@ -653,7 +653,7 @@ function updateGraphTable(channelId, times){
// On the same connection, update each person's time.
for(let viewer in times){

pool.query("UPDATE ? SET \`?\`=? WHERE username=?;",
connection.query("UPDATE ? SET \`?\`=? WHERE username=?;",
[channelId, today, times[viewer],
viewer], function(error){

Expand Down Expand Up @@ -965,6 +965,7 @@ function _assertError(err, connection, res=undefined){
connection.release();
}
catch(error){
logger.error("Connection already released.")
}
if(res != undefined){
res.writeHead(json.badRequest);
Expand Down
16 changes: 10 additions & 6 deletions backend/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const server = https.createServer(options, function(req, res){
if(response != undefined){
response = response[0];
const displayName = response["display_name"];
res.setHeader("name", displayName);
res.setHeader("name", encodeURIComponent(displayName));
}

// Then we end and return because we don't want the
Expand All @@ -202,7 +202,9 @@ const server = https.createServer(options, function(req, res){

// If viewer can't be found in the channel's trackers, add
// them to it and the SQL tables.
if(!trackers[channelId].hasOwnProperty(displayName) &&
if(trackers.hasOwnProperty(channelId) &&
whitelisted.hasOwnProperty(channelId) &&
!trackers[channelId].hasOwnProperty(displayName) &&
!whitelisted[channelId].hasOwnProperty(displayName)){
sql.addViewer(channelId, response["id"], displayName);
sql.addViewerGraphTable(channelId, response["id"],
Expand Down Expand Up @@ -502,7 +504,7 @@ const server = https.createServer(options, function(req, res){

const requestPayload = jwt.parse(req.headers["extension-jwt"]).
payloadObj;
const viewer = req.headers["viewerqueriedfor"];
const viewer = decodeURIComponent(req.headers["viewerqueriedfor"]);
const channelId = requestPayload["channel_id"];
let isWhitelisted = false;

Expand All @@ -519,7 +521,8 @@ const server = https.createServer(options, function(req, res){

// Check if request from actualy from the client that's being
// paused.
if(trackers[channelId][viewer] != undefined){
if(trackers[channelId] != undefined
&& trackers[channelId][viewer] != undefined){
if(requestPayload["user_id"] !=
trackers[channelId][viewer].user){
res.writeHead(json.forbidden, headers);
Expand All @@ -530,7 +533,8 @@ const server = https.createServer(options, function(req, res){
}
}

else if(whitelisted[channelId][viewer] != undefined){
else if(whitelisted[channelId] != undefined
&& whitelisted[channelId][viewer] != undefined){
if(requestPayload["user_id"] !=
whitelisted[channelId][viewer].user){
res.writeHead(json.forbidden, headers);
Expand Down Expand Up @@ -1017,7 +1021,7 @@ function _checkJWT(req, res){
!jwt.verifyJWT(req.headers["extension-jwt"],
{"b64": json.secret}, {alg: [json.alg]})){

res.writeHead(json.forbidden, headers);
res.writeHead(json.forbidden, json.headers);
res.end();
return false;
}
Expand Down
1 change: 1 addition & 0 deletions backend/config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"webhookPath": "/helix/webhooks/hub",
"getWebhooksPath": "/helix/webhooks/subscriptions",
"tokenPath": "/oauth2/token",
"tokenRefreshPath": "/oauth2/token--data-urlencode",

"alg": "YOUR_PREFERRED_ENCRYPTION_ALGORITHM_HERE",

Expand Down

0 comments on commit 7f00bc6

Please sign in to comment.