diff --git a/frontend/src/App.js b/frontend/src/App.js index 6670079..23466b2 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -29,6 +29,191 @@ var IMAGE_CAMERA=(p)=>{ ) } +var IMAGE_BUG=(p)=>{ + return( + + + + ) +} +var IMAGE_CONTROLLER=(p)=>{ + return( + + + + + + ) +} +var IMAGE_ARCADE=(p)=>{ + return( + + + + + + ) +} +var IMAGE_TABLET=(p)=>{ + return( + + + + + ) +} +var IMAGE_MIXMODE=(p)=>{ + return( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} +var IMAGE_JOYCONS=(p)=>{ + return( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} var RATING_cool=new Image(); RATING_cool.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAAAWCAYAAABjadrAAAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSkVaHOwg4pChOlkVFXGUKhbBQmkrtOpgcukfNGlIUlwcBdeCgz+LVQcXZ10dXAVB8AfEydFJ0UVK/C4ptIjxjuMe3vvel7vvAKFRYarZNQGommWk4jExm1sVA68IIERzDOMSM/VEejEDz/F1Dx/f76I8y7vuzxFS8iYDfCLxHNMNi3iDeGbT0jnvE4dZSVKIz4lHDbog8SPXZZffOBcdFnhm2Mik5onDxGKxg+UOZiVDJZ4mjiiqRvlC1mWF8xZntVJjrXvyFwbz2kqa67SGEMcSEkhChIwayqjAQpR2jRQTKTqPefgHHX+SXDK5ymDkWEAVKiTHD/4Hv3trFqYm3aRgDOh+se2PYSCwCzTrtv19bNvNE8D/DFxpbX+1Acx+kl5va5EjoG8buLhua/IecLkDDDzpkiE5kp+WUCgA72f0TTmg/xboXXP71jrH6QOQoV4t3wAHh8BIkbLXPd7d09m3f2ta/fsBxMxyyECtw/8AAAAGYktHRAAAAAAAAPlDu38AAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfkBw0VBxxA5lzqAAAAGXRFWHRDb21tZW50A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UB9W4RFp1bZvWDhhRCEWIrewuK23D1DOHGNuy+/VPz777w48vTnPn85ShPiUSXdvtR/SzbAqdWpZawr1GzLY9L3D0m9+TdZt20leJr37ywT8e/9+TK4xvCPTFAWN0zX8+rCgCBBG6mTDfgNl0PTufep7+/nVcu3CcC5+2uVsPROUpgPD/X0Eci92ULIcoimvsnjxCVNkgZ0+917h6+aPB1s37ZGmXEMLaYvR3zloVUUEiy+iWSQ4f+WPZvvMg23dMvXHi1z/X69fO0GreK1wzv0cLjKFSW8+m0Z1MPff83xx+/tt/u3vyAIGIykv9H1QHhuXjj97Tj29fIu0sEoJb8ym/I7zWElfXsWF4K1/40guvT+x9/o00abO02NYz17pkSecRIX/sEeBDOmSr/ezd/yXk4pVzRZOqjtbKErMzt2k2FoszWUKt3KPkt2GXMtONsQxt2szE5BRxZYAQchYWZpi7/zmt9hIh5OVZcqE8USVCjCE2MRIb6vUBNm7azNatuxlcP0oQSyvNyENOHnIWF+dYmL1D0m2Bzx8sQ8Cp4DGgEImiScbQuiE2Dm+hEveTpwlLyzMsLEyTZQ5jhBA8GgI2shhjwQhqIwxKbC3VuIqNI6qVOtu27+T/AMjSqGcQRJbnAAAAAElFTkSuQmCC" @@ -172,7 +357,7 @@ function Sort(p){ function ProfileDataContainer(p){ return (
{if (p.setMouseOver) {p.setMouseOver(true)}}} onMouseOut={()=>{if(p.setMouseOver){p.setMouseOver(false)}}}> -
+
{p.label}
@@ -605,7 +790,7 @@ function BestPlaysPanel(p) { useEffect(()=>{ axios.get("http://www.projectdivar.com/bestplays/"+p.username+"?fails=false&limit=5&offset=0") .then((data)=>{setBestPlays(data.data);}) - },[update]) + },[update,p.username]) var content=
    @@ -788,7 +973,7 @@ function CompletionPanel(p) { axios.get("http://projectdivar.com/completionreport/"+p.username) .then((data)=>{setReport(data.data)}) .catch((err)=>{console.log(err.message)}) - },[update]) + },[update,p.username]) return ( <> @@ -870,6 +1055,30 @@ function ClearBadge(p) { ) } + +function FavoritePlaystyle(p) { + switch (p.playstyle){ + case "PS4 Controller":{ + return + } + case "Joycons":{ + return + } + case "Mix Mode":{ + return + } + case "Arcade Controller":{ + return + } + case "Touch Screen":{ + return + } + default:{ + return <> + } + } +} + function Profile(p){ let { username } = useParams(); let match = useRouteMatch(); @@ -903,7 +1112,8 @@ function Profile(p){ .then((data)=>{setUserData(data.data);setPlayCount(data.data.playcount);setFCCount(data.data.fccount);setRating(data.data.rating);setLastPlayed(data.data.last_played);setAccuracy(CalculateAccuracy(data.data.cool,data.data.fine,data.data.safe,data.data.sad,data.data.worst))}); axios.get("http://projectdivar.com:4501/songdiffs") .then((data)=>{setDiffs(data.data)}) - },[update]) + setModalVisible(false); + },[update,username]) useEffect(()=>{ if (user!={}) { @@ -920,6 +1130,12 @@ function Profile(p){

    {username+"'s Profile"}

    {(render)?<> + {user.playstyle&&user.playstyle.length>0&& +
    +
    + +
    +
    } @@ -979,6 +1195,16 @@ function ImageUpload(p) { var [error,setError] = useState(null); var [success,setSuccess] = useState(null); var [fileProgress,setFileProgress] = useState(0); + var [update,setUpdate] = useState(false); + var [authToken,setAuthToken] = useState(false); + + useEffect(()=>{ + axios.post("http://projectdivar.com/authenticate/authToken",{username:localStorage.getItem("username"), + authCode:localStorage.getItem("authToken")}) + .then((data)=>{ + setAuthToken(data.data.authentication_token) + }) + },[update]) var prepFile = (e)=>{ setFile(e.currentTarget.files[0]) @@ -995,8 +1221,8 @@ function ImageUpload(p) { } const data = new FormData() data.append('file', file) - data.append("username","GOD"); - data.append("authentication_token","GOD"); + data.append("username",localStorage.getItem("username")); + data.append("authentication_token",authToken); if (!data.has("username") || !data.has("authentication_token")) {setError("Authentication failed!");return;} if (file.size>15*1024*1024) { @@ -1131,15 +1357,6 @@ function SimpleUpload(p){ ) } -function SendMail() { - //process.env.REACT_APP_FRONTEND_AUTH - return ( - <> - - - ) -} - function Submit(p) { return (
    @@ -1152,14 +1369,34 @@ function Submit(p) { Detailed - Switch +

    Nintendo Switch/Twitter Upload

    + Want to upload your scores to the website conveniently? Go to Edit Profile Settings and enter your Twitter username, then follow the steps below! +
    +
    +
    +

    Step 1

    + From your Nintendo Switch Album, select up to 4 results screenshots that you want the DivaRBot to parse. +
    +
    + +
    +
    +
    +
    + +
    +
    +

    Step 2

    + Make sure to include @divarbot so the bot can find your plays! Then submit and the bot will process them in just a few minutes! Check your scores out after they have been processed. +
    +

    Select a submission method

    -
    + {false&&<>
    Manual Submit
    @@ -1168,7 +1405,7 @@ function Submit(p) {
    -
    +
    }
    @@ -1223,6 +1460,7 @@ function LoginInfo(p) { const [username,setUsername] = useState(undefined) const [authToken,setAuthToken] = useState(undefined) const [loggedIn,setLoggedIn] = useState(false) + //Load our storage data if exists. useEffect(()=>{ try { @@ -1239,6 +1477,7 @@ function LoginInfo(p) { .then((data)=>{ setLoggedIn(true); p.setUsername(username); + p.setUserSettings(data.data) }) .catch((err)=>{ setLoggedIn(false); @@ -1250,6 +1489,8 @@ function LoginInfo(p) { <> {loggedIn?<> Welcome, {username}!
    + My Profile
    + Edit Profile Settings
    App Auth Code
    :<> @@ -1430,6 +1671,66 @@ function Register(p) { ) } +function UserSettings(p) { + let history = useHistory(); + const [playStyle,setPlayStyle] = useState(p.userSettings.playstyle) + const [playStyleHover,setPlayStyleHover] = useState(undefined) + const [twitter,setTwitter] = useState(p.userSettings.twitter_name) + const [twitterChange,setTwitterChange] = useState(false) + const [message,setMessage] = useState(false) + const [error,setError] = useState(false) + + if (p.username===undefined) { + history.push("/") + } + + return ( + <> + {setPlayStyleHover(undefined)}}> + Favorite Playstyle - {playStyle} +
    + + + + + + + {playStyleHover?<>Change playstyle to {playStyleHover}:<>Your playstyle will be included in your submitted plays.} + +
    +
    + {setPlayStyleHover(undefined)}}> + Twitter Username: + {setTwitter(e.currentTarget.value);setTwitterChange(true)}} value={twitter} placeholder="MikuMiku"/> + + If you input your Twitter username, you can submit screenshots to @divarbot (with "@divarbot" in the message) and your plays will auto-submit from Twitter at any time. + + + + {message&&

    {message}

    } + {error&&

    {error}

    } + + ) +} + function UserAuth(p) { const[showAuthCode,setShowAuthCode] = useState(false) const[authToken,setAuthToken] = useState("") @@ -1468,7 +1769,7 @@ function ReleaseList(p) { @@ -1478,9 +1779,11 @@ function ReleaseList(p) { function DivaBot() { const releases=[ - ["01B","http://projectdivar.com/files/releases/DivaBot01B.zip","13 Sep 2020"], - ["01A","http://projectdivar.com/files/releases/DivaBot01A.zip","13 Sep 2020"], - ["01","http://projectdivar.com/files/releases/DivaBot01.zip","13 Sep 2020"]] + ["02A","http://projectdivar.com/files/releases/DivaBot02A.zip","14 Sep 2020",<>Recommended! Label Headers and Redo Song Calibration features added], + ["02","http://projectdivar.com/files/releases/DivaBot02.zip","14 Sep 2020",<>Stable], + ["01B","http://projectdivar.com/files/releases/DivaBot01B.zip","13 Sep 2020",<> BUGGED! DO NOT USE!], + ["01A","http://projectdivar.com/files/releases/DivaBot01A.zip","13 Sep 2020",<> BUGGED! DO NOT USE! Speed Improvements], + ["01","http://projectdivar.com/files/releases/DivaBot01.zip","13 Sep 2020",<> BUGGED! DO NOT USE! Initial Release]] return ( <> @@ -1497,6 +1800,12 @@ function DivaBot() {

    Downloads

    +
    +

    Repository - Open Source Software

    + I don't believe in keeping things secret and you shouldn't be open to just downloading whatever you find on the Internet. +

    This app and Project DivaR itself is open source. You can find its source code at this link. +

    + If you need an open discussion about how this program works or have any feedbacks/concerns, please contact me via the Project DivaR Discord server (@sigonasr2). ) } @@ -1507,6 +1816,7 @@ function Website() { const [tooltip,setTooltip] = useState("") const [loginPanelUpdate,setLoginPanelUpdate] = useState(false) const [username,setUsername] = useState(undefined) + const [userSettings,setUserSettings] = useState({}) useEffect(()=>{ axios.get("http://www.projectdivar.com/songs") @@ -1519,10 +1829,13 @@ function Website() {

    Menu

    - +

    Rankings
    + Submit Scores
    DivaBot
    +
    +
    @@ -1534,6 +1847,11 @@ function Website() { :<> } + + { + + } + diff --git a/frontend/src/setupProxy.js b/frontend/src/setupProxy.js index 6c30759..9f6e2cb 100644 --- a/frontend/src/setupProxy.js +++ b/frontend/src/setupProxy.js @@ -1,6 +1,20 @@ const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = function(app) { + app.use( + "/updateuser", + createProxyMiddleware({ + target: 'http://server:4501', + changeOrigin: true, + }) + ); + app.use( + "/findsong/:songname", + createProxyMiddleware({ + target: 'http://server:4501', + changeOrigin: true, + }) + ); app.use( "/authenticate/authToken", createProxyMiddleware({ diff --git a/imgparser/projectDivaImgParser b/imgparser/projectDivaImgParser index c23231e..cdfe63f 160000 --- a/imgparser/projectDivaImgParser +++ b/imgparser/projectDivaImgParser @@ -1 +1 @@ -Subproject commit c23231e281c8d55f275be235158f326244e1c445 +Subproject commit cdfe63fec298f37a70d3b34ac90cb5cd2a45b479 diff --git a/server/app.js b/server/app.js index 73d3c2b..37539eb 100644 --- a/server/app.js +++ b/server/app.js @@ -113,12 +113,11 @@ app.delete('/remove',(req,res)=>{ .then((data)=>{if(data && data.rows.length>0){res.status(200).json({user:data.rows[0],song:songObj})}else{throw new Error("Could not update user information, but song is deleted!")}}) .catch((err)=>{res.status(500).json(err.message)}) } else { - res.status(400).json("Missing required parameters!"); + res.status(400).send("Missing required parameters!"); } }) app.post('/upload', function(req, res) { - if (!req.files || Object.keys(req.files).length === 0 || req.body.username===undefined || req.body.authentication_token===undefined) { res.status(400).send('No files were uploaded. Invalid parameters.'); return; @@ -133,8 +132,7 @@ app.post('/upload', function(req, res) { } if (file.mimetype!=="application/x-zip-compressed" && - file.mimetype!=="image/jpeg" && file.mimetype!=="image/png") { - res.status(400).send('File type is invalid!'); + file.mimetype!=="image/jpeg" && file.mimetype!=="image/png" && file.mimetype!=="application/octet-stream") { return; } @@ -164,7 +162,12 @@ app.post('/upload', function(req, res) { }}) .then((data)=>{ if (file.mimetype!=="application/x-zip-compressed") { - return axios.post("http://projectdivar.com/image",{url:"http://projectdivar.com/"+fileLoc,user:req.body.username,auth:req.body.authentication_token}) + if (req.body.playid!==undefined) { + //Add the url to that play. + return db.query("update plays set src=$1 where id=$2 and userid=$3",["http://projectdivar.com/"+fileLoc,Number(req.body.playid),userId]) + } else { + return axios.post("http://projectdivar.com/image",{url:"http://projectdivar.com/"+fileLoc,user:req.body.username,auth:req.body.authentication_token}) + } } else { //This is a zip file. var promises = [] @@ -208,7 +211,6 @@ app.post('/upload', function(req, res) { } }) .catch((err)=>{console.log(err.message);res.status(500).send(err.message)}) - }); app.post('/submit', (req, res) => { @@ -232,7 +234,7 @@ app.post('/submit', (req, res) => { if (!(req.body.difficulty==="H"||req.body.difficulty==="N"||req.body.difficulty==="E"||req.body.difficulty==="EX"||req.body.difficulty==="EXEX")) {throw new Error("Invalid difficulty!")} - var songsubmitdata={},mod="",combo=-1,gameScore=-1,isFC=false,songRating=-1,userId = -1,songId=-1,playcount=-1,fccount=-1,cool=-1,fine=-1,safe=-1,sad=-1,worst=-1,alreadyPassed=false,eclear=-1,nclear=-1,hclear=-1,exclear=-1,exexclear=-1; + var playstyle="",songsubmitdata={},mod="",combo=-1,gameScore=-1,isFC=false,songRating=-1,userId = -1,songId=-1,playcount=-1,fccount=-1,cool=-1,fine=-1,safe=-1,sad=-1,worst=-1,alreadyPassed=false,eclear=-1,nclear=-1,hclear=-1,exclear=-1,exexclear=-1; if (req.body.mod!==undefined) { mod = req.body.mod; @@ -244,16 +246,17 @@ app.post('/submit', (req, res) => { gameScore = req.body.gameScore; } - db.query("select id,authentication_token,playcount,fccount,cool,fine,safe,sad,worst,eclear,nclear,hclear,exclear,exexclear from users where username=$1 limit 1",[req.body.username]) + db.query("select id,authentication_token,playcount,fccount,cool,fine,safe,sad,worst,eclear,nclear,hclear,exclear,exexclear,playstyle from users where username=$1 limit 1",[req.body.username]) .then((data)=>{if(data && data.rows.length>0){if (data.rows[0].authentication_token===req.body.authentication_token){ var obj = data.rows[0]; + playstyle=data.rows[0].playstyle; eclear=obj.eclear;nclear=obj.nclear;hclear=obj.hclear;exclear=obj.exclear;exexclear=obj.exexclear; cool=data.rows[0].cool;fine=data.rows[0].fine;safe=data.rows[0].safe;sad=data.rows[0].sad;worst=data.rows[0].worst; fccount=data.rows[0].fccount;playcount=data.rows[0].playcount;userId=data.rows[0].id;return db.query("select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1",[req.body.song])}else{throw new Error("Could not authenticate!")}}else{throw new Error("Could not find user.")} }) .then((data)=>{if(data && data.rows.length>0){songId=data.rows[0].id; return db.query('select rating from songdata where songid=$1 and difficulty=$2 limit 1',[songId,req.body.difficulty])}else{throw new Error("Could not find song.")}}) .then((data)=>{songRating=data.rows[0].rating;return db.query("select id from plays where userid=$1 and score>0 and difficulty=$2 and songid=$3 limit 1",[userId,req.body.difficulty,songId])}) - .then((data)=>{if(data && data.rows.length>0){alreadyPassed=true;/*console.log(data);*/};var score=CalculateSongScore({rating:songRating,cool:req.body.cool,fine:req.body.fine,safe:req.body.safe,sad:req.body.sad,worst:req.body.worst,percent:req.body.percent,difficulty:req.body.difficulty,fail:fail});return db.query("insert into plays(songId,userId,difficulty,cool,fine,safe,sad,worst,percent,date,score,fail,mod,combo,gamescore,src) values($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16) returning *",[songId,userId,req.body.difficulty,req.body.cool,req.body.fine,req.body.safe,req.body.sad,req.body.worst,req.body.percent,submitDate,score,fail,mod,combo,gameScore,(req.body.src)?req.body.src:""])}) + .then((data)=>{if(data && data.rows.length>0){alreadyPassed=true;/*console.log(data);*/};var score=CalculateSongScore({rating:songRating,cool:req.body.cool,fine:req.body.fine,safe:req.body.safe,sad:req.body.sad,worst:req.body.worst,percent:req.body.percent,difficulty:req.body.difficulty,fail:fail});return db.query("insert into plays(songId,userId,difficulty,cool,fine,safe,sad,worst,percent,date,score,fail,mod,combo,gamescore,src,playstyle) values($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17) returning *",[songId,userId,req.body.difficulty,req.body.cool,req.body.fine,req.body.safe,req.body.sad,req.body.worst,req.body.percent,submitDate,score,fail,mod,combo,gameScore,(req.body.src)?req.body.src:"",(playstyle)?playstyle:""])}) .then((data)=>{if(data && data.rows.length>0){ songsubmitdata = data.rows[0]; //console.log(alreadyPassed+" / "+typeof(alreadyPassed)) @@ -266,10 +269,10 @@ app.post('/submit', (req, res) => { .catch((err)=>{ //console.log(req.body); //console.log(err); - res.status(500).json(err.message);}) + res.status(500).send(err.message);}) } else { console.log(req.body); - res.status(400).json("Missing required parameters!"); + res.status(400).send("Missing required parameters!"); } }) @@ -336,14 +339,14 @@ app.get('/songdiffs',(req,res)=>{ .then((data)=>{diffObj.H=data.rows[0].count;return db.query("select COUNT(*) from songdata where difficulty='EX'")}) .then((data)=>{diffObj.EX=data.rows[0].count;return db.query("select COUNT(*) from songdata where difficulty='EXEX'")}) .then((data)=>{diffObj.EXEX=data.rows[0].count;res.status(200).json(diffObj)}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/accuracy/:username',(req,res)=>{ db.query('select cool,fine,safe,sad,worst from users where username=$1',[req.params.username]) .then((data)=>{if (data.rows.length>0){return CalculateAccuracy(data.rows[0].cool,data.rows[0].fine,data.rows[0].safe,data.rows[0].sad,data.rows[0].worst)}else{throw new Error("User does not exist!")}}) .then((data)=>{res.status(200).json({accuracy:data})}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/recalculatescore/:playid',(req,res)=>{ @@ -362,7 +365,7 @@ app.get('/recalculatescore/:playid',(req,res)=>{ return db.query('select username from users where id=$1',[userId]).then((data)=>{username=data.rows[0].username; return CalculateRating(username)}).then((data)=>{db.query("update users set rating=$1 where username=$2",[data,username])}) .then(()=>{return scoreData;}) }else{throw new Error("Failed to update score!")}}) - .then((data)=>res.status(200).json(data)).catch((err)=>{console.log(err);res.status(500).json(err.message);}) + .then((data)=>res.status(200).json(data)).catch((err)=>{console.log(err);res.status(500).send(err.message);}) }); /* @@ -402,7 +405,7 @@ app.get('/completionreport/:username',(req,res)=>{ .then((data)=>{ return res.status(200).json(songs); }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/ratings/:songname/:username',(req,res)=>{ @@ -427,7 +430,7 @@ app.get('/ratings/:songname/:username',(req,res)=>{ .then((data)=>{ res.status(200).json(data.rows) }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) @@ -440,21 +443,21 @@ app.get('/bestplays/:username',(req,res)=>{ .then((data)=>{ res.status(200).json(data.rows) }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/bestplay/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;if(req.params.songname){return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{return db.query('select * from plays where userid=$1 order by score desc',[userId])}}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 order by score desc,percent desc limit 1',[userId,songId,req.params.difficulty])}else{res.status(400).json("Could not find song!")}}) - .then((data)=>{if(data && data.rows.length>0){res.status(200).json(data.rows[0])}else{res.status(400).json("No data found!")}}) - .catch((err)=>{res.status(500).json(err.message+JSON.stringify(req.body))}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 order by score desc,percent desc limit 1',[userId,songId,req.params.difficulty])}else{res.status(400).send("Could not find song!")}}) + .then((data)=>{if(data && data.rows.length>0){res.status(200).json(data.rows[0])}else{res.status(400).send("No data found!")}}) + .catch((err)=>{res.status(500).send(err.message+JSON.stringify(req.body))}) }) app.get('/userdata/:username',(req,res)=>{ var songId=-1,userId=-1,finalData={}; - db.query('select playcount,fccount,rating,last_played,cool,fine,safe,sad,worst,eclear,nclear,hclear,exclear,exexclear from users where username=$1 limit 1',[req.params.username]) + db.query('select playstyle,playcount,fccount,rating,last_played,cool,fine,safe,sad,worst,eclear,nclear,hclear,exclear,exexclear from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if(data && data.rows.length>0){finalData=data.rows[0];return db.query("select t.difficulty,COUNT(t.difficulty) from (select distinct on(songid) songid,*,users.id from plays join users on userid=users.id where users.username=$1 and plays.safe=0 and plays.worst=0 and plays.sad=0)t group by t.difficulty",[req.params.username])}else{throw new Error("Could not retrieve user data!")}}) .then((data)=>{ if (data) { @@ -472,7 +475,7 @@ app.get('/userdata/:username',(req,res)=>{ res.status(200).json(finalData) }else{throw new Error("Could not retrieve user data!")} }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/plays/:username/:songid',(req,res)=>{ @@ -483,50 +486,50 @@ app.get('/plays/:username/:songid',(req,res)=>{ .then((data)=>{ res.status(200).json(data.rows) }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/playcount/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 order by score desc',[userId,songId,req.params.difficulty])}else{res.status(400).json("Could not find song!")}}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 order by score desc',[userId,songId,req.params.difficulty])}else{res.status(400).send("Could not find song!")}}) .then((data)=>{if(data && data.rows.length>0){res.status(200).json({playcount:data.rows.length})}else{res.status(200).json({playcount:0})}}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/songpasscount/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and score>0',[userId,songId,req.params.difficulty])}else{res.status(400).json("Could not find song!")}}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and score>0',[userId,songId,req.params.difficulty])}else{res.status(400).send("Could not find song!")}}) .then((data)=>{if(data && data.rows.length>0){res.status(200).json({passcount:data.rows.length})}else{res.status(200).json({passcount:0})}}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/songfccount/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and safe=0 and sad=0 and worst=0',[userId,songId,req.params.difficulty])}else{res.status(400).json("Could not find song!")}}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and safe=0 and sad=0 and worst=0',[userId,songId,req.params.difficulty])}else{res.status(400).send("Could not find song!")}}) .then((data)=>{if(data && data.rows.length>0){res.status(200).json({fccount:data.rows.length})}else{res.status(200).json({fccount:0})}}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/songpfccount/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and fine=0 and safe=0 and sad=0 and worst=0',[userId,songId,req.params.difficulty])}else{res.status(400).json("Could not find song!")}}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select * from plays where userid=$1 and songid=$2 and difficulty=$3 and fine=0 and safe=0 and sad=0 and worst=0',[userId,songId,req.params.difficulty])}else{res.status(400).send("Could not find song!")}}) .then((data)=>{if(data && data.rows.length>0){res.status(200).json({fccount:data.rows.length})}else{res.status(200).json({fccount:0})}}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/songmods/:username/:songname/:difficulty',(req,res)=>{ var songId=-1,userId=-1,hs=0,sd=0,hd=0; db.query('select id from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if (data.rows.length>0){userId=data.rows[0].id;return db.query('select id from songs where name=$1 or romanized_name=$1 or english_name=$1 limit 1', [req.params.songname])}else{throw new Error("Cannot find user!")}}) - .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select COUNT(mod) from (select * from plays where userid=$1 and songid=$2 and difficulty=$3 and mod=$4)t',[userId,songId,req.params.difficulty,"HS"])}else{res.status(400).json("Could not find song!")}}) + .then((data)=>{if(req.params.songname &&data.rows.length>0){songId=data.rows[0].id;return db.query('select COUNT(mod) from (select * from plays where userid=$1 and songid=$2 and difficulty=$3 and mod=$4)t',[userId,songId,req.params.difficulty,"HS"])}else{res.status(400).send("Could not find song!")}}) .then((data)=>{if(data && data.rows.length>0){ hs=data.rows[0].count; } @@ -542,7 +545,7 @@ app.get('/songmods/:username/:songname/:difficulty',(req,res)=>{ } res.status(200).json({hs:hs,sd:sd,hd:hd}) }) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) }) app.get('/rating/:username',(req,res)=>{ @@ -550,7 +553,7 @@ app.get('/rating/:username',(req,res)=>{ db.query('select rating from users where username=$1 limit 1',[req.params.username]) .then((data)=>{if(data.rows.length>0){res.status(200).json(data.rows[0])}else{res.status(200).json({rating:0})}}) } else { - res.status(400).json("Invalid username!") + res.status(400).send("Invalid username!") } }) @@ -559,7 +562,7 @@ app.get('/recentplays/:username',(req,res)=>{ db.query('select plays.* from plays join users on users.id=plays.userid where users.username=$1 order by plays.id desc limit 10',[req.params.username]) .then((data)=>{if(data.rows.length>0){res.status(200).json(data.rows)}else{res.status(200).json([])}}) } else { - res.status(400).json("Invalid username!") + res.status(400).send("Invalid username!") } }) @@ -570,12 +573,12 @@ app.get('/users/:orderby/:sortorder',(req,res)=>{ if (valid.includes(req.params.orderby) && validsort.includes(req.params.sortorder)) { db.query('select username,rating,last_played,playcount,fccount from users order by '+req.params.orderby+' '+req.params.sortorder+",rating desc limit $1 offset $2",[req.query.limit,req.query.offset]) .then((data)=>{return res.status(200).json(data.rows)}) - .catch((err)=>{res.status(500).json(err.message)}) + .catch((err)=>{res.status(500).send(err.message)}) } else { - res.status(400).json("Not a valid sort option!"); + res.status(400).send("Not a valid sort option!"); } } else { - res.status(400).json("Invalid query!") + res.status(400).send("Invalid query!") } }) @@ -701,9 +704,9 @@ app.post('/song/:songname/:difficulty',(req,res)=>{ .then((data)=>{ res.status(200).json(data.data) }) - .catch((err)=>{res.status(400).json(err.message)}) + .catch((err)=>{res.status(400).send(err.message)}) } else { - res.status(400).json("Invalid query!") + res.status(400).send("Invalid query!") } }) @@ -761,7 +764,7 @@ function GetUserInfo(username) { return db.query("select id,username,email,code_time from users where username=$1 limit 1",[username]) } function GetUserLoginAllowed(username,authCode) { - return db.query("select id,username,email,code_time from users where username=$1 and code=$2 limit 1",[username,authCode]) + return db.query("select id,username,email,code_time,playstyle,twitter_name from users where username=$1 and code=$2 limit 1",[username,authCode]) } app.post('/authenticate/authToken',(req,res)=>{ if (req.body&&req.body.username&&req.body.authCode) { @@ -781,10 +784,10 @@ app.post('/authenticate/authToken',(req,res)=>{ } }) .catch((err)=>{ - res.status(500).json(err.message) + res.status(500).send(err.message) }) } else { - res.status(400).json("Invalid Credentials!") + res.status(400).send("Invalid Credentials!") } }) @@ -793,13 +796,13 @@ app.post('/authenticate/login',(req,res)=>{ GetUserLoginAllowed(req.body.username.trim(),req.body.authCode.trim()) .then((data)=>{ if (data.rows.length>0) { - res.status(200).json("Login allowed!") + res.status(200).json(data.rows[0]) } else { - res.status(400).json("Failed login!") + return new Error("Failed login!") } }) } else { - res.status(400).json("Invalid Credentials!") + res.status(400).send("Invalid Credentials!") } }) @@ -808,7 +811,7 @@ app.post('/sendemail/login',function(req,res) { GetUserInfo(req.body.username.trim()) .then((data)=>{ if (data.rows.length>0) { - res.status(200).json("Email sent.") + res.status(200).send("Email sent.") //console.log(data.rows[0].code_time) if (data.rows[0].code_time) { if (moment(data.rows[0].code_time,"YYYY-MM-DD HH:mm:ss.SSSZ").diff(moment(),'minutes')<=-15) { @@ -823,11 +826,14 @@ app.post('/sendemail/login',function(req,res) { db.query("update users set code=$1,code_time=$3 where id=$2",[authCode,data.rows[0].id,moment()]) } } else { - res.status(400).json("User does not exist!") + return new Error("User does not exist!") } }) + .catch((err)=>{ + res.status(500).send(err.message) + }) } else { - res.status(400).json("Invalid credentials!") + res.status(400).send("Invalid credentials!") } }) @@ -842,13 +848,13 @@ app.patch('/updateRegisteredState',function(req,res) { } }) .then((data)=>{ - res.status(200).json("Registered!") + res.status(200).send("Registered!") }) .catch((err)=>{ - res.status(500).json("Could not finish registration!") + res.status(500).send("Could not finish registration!") }) } else { - res.status(400).json("Invalid credentials!") + res.status(400).send("Invalid credentials!") } }) @@ -873,17 +879,17 @@ app.post('/sendemail/register',function(req,res) { }) .then((data)=>{ if (data.rows.length>0) { - res.status(200).json("Email sent.") + res.status(200).send("Email sent.") SendRegistrationEmail(req.body.username,req.body.email,data.rows[0].code) } else { - res.status(500).json("Something bad happened!") + throw new Error("Something bad happened!") } }) .catch((err)=>{ - res.status(500).json(err.message) + res.status(500).send(err.message) }) } else { - res.status(400).json("Invalid credentials!") + res.status(400).send("Invalid credentials!") } }) @@ -896,31 +902,57 @@ app.post('/authenticateuser',function(req,res) { AuthenticateUser(req.body.username.trim(),req.body.authenticationToken.trim()) .then((data)=>{ if (data.rows.length>0) { - res.status(200).json("Authentication Success!") + res.status(200).send("Authentication Success!") } else { - res.status(400).json("Authentication Failed!") + throw new Error("Authentication Failed!") } }) .catch((err)=>{ - res.status(500).json(err.message) + res.status(500).send(err.message) }) } else { - res.status(400).json("Invalid credentials!") + res.status(400).send("Invalid credentials!") } }) -/* -app.get('/twitter/mentions', function(req, res) { - if (req.query.data) { - console.log(req.query.data) - res.status(200).json("OK!") +app.post('/updateuser', function(req, res) { + var userId=-1; + if (req.body&&req.body.playStyle&&req.body.username&&req.body.authCode) { + GetUserLoginAllowed(req.body.username ,req.body.authCode) + .then((data)=>{ + if (data.rows.length>0) { + userId=data.rows[0].id + if (req.body.twitterName) { + return axios.get('https://api.twitter.com/1.1/users/show.json?screen_name='+req.body.twitterName, { + headers: { + /*BEARER*/ Authorization: 'Bearer '+process.env.TWITTER_BEARER //the token is a variable which holds the token + } + }) + } else { + return {data:{}} + } + } else { + throw new Error("Could not login!") + } + }) + .then((data)=>{ + if (data.data.id) { + return db.query("update users set playstyle=$1,twitter=$2,twitter_name=$3 where id=$4",[req.body.playStyle,data.data.id,req.body.twitterName,userId]) + } else { + return db.query("update users set playstyle=$1 where id=$2",[req.body.playStyle,userId]) + } + }) + .then((data)=>{ + res.status(200).send("Successfully updated user settings!") + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) } else { - res.status(400).json("Empty input") + res.status(400).send("Invalid credentials!") } }) -const pixels = require("get-pixels"); -*/ @@ -1001,14 +1033,19 @@ setInterval( }) .catch((err)=>{console.log(err)}) } -,5000) +,1000) setInterval(()=>{db.query("select * from twitter_bot limit 1") .then((data)=>{ largestId=filterId=data.rows[0].lastpost; //console.log("Filter Id: "+filterId); - return axios.get('https://api.twitter.com/1.1/search/tweets.json?q=%23mega39s', { + /*return axios.get('https://api.twitter.com/1.1/search/tweets.json?q=%23mega39s', { + headers: { + Authorization: 'Bearer '+process.env.TWITTER_BEARER //the token is a variable which holds the token + } + })*/ + return axios.get('https://api.twitter.com/1.1/search/tweets.json?q=@divarbot', { headers: { Authorization: 'Bearer '+process.env.TWITTER_BEARER //the token is a variable which holds the token } diff --git a/server/files/DivaBot_small.png b/server/files/DivaBot_small.png new file mode 100644 index 0000000..052373e Binary files /dev/null and b/server/files/DivaBot_small.png differ diff --git a/server/files/discord_button_small.png b/server/files/discord_button_small.png new file mode 100644 index 0000000..76ed25c Binary files /dev/null and b/server/files/discord_button_small.png differ diff --git a/server/files/rankings_small.png b/server/files/rankings_small.png new file mode 100644 index 0000000..31f47f3 Binary files /dev/null and b/server/files/rankings_small.png differ diff --git a/server/files/releases/DivaBot02.zip b/server/files/releases/DivaBot02.zip new file mode 100644 index 0000000..ac07208 Binary files /dev/null and b/server/files/releases/DivaBot02.zip differ diff --git a/server/files/releases/DivaBot02A.zip b/server/files/releases/DivaBot02A.zip new file mode 100644 index 0000000..66099c3 Binary files /dev/null and b/server/files/releases/DivaBot02A.zip differ diff --git a/server/files/switch1.png b/server/files/switch1.png new file mode 100644 index 0000000..31a6c44 Binary files /dev/null and b/server/files/switch1.png differ diff --git a/server/files/switch2.png b/server/files/switch2.png new file mode 100644 index 0000000..d070b5c Binary files /dev/null and b/server/files/switch2.png differ