2019-11-18 18:39:17 -05:00
const crypto = require ( 'crypto' )
function sha1 ( data ) { return crypto . createHash ( "sha1" ) . update ( data , "binary" ) . digest ( "hex" ) ; }
module . exports = async ( app , req , res ) => {
2021-12-07 11:06:33 -08:00
if ( req . method !== 'POST' ) return res . status ( 405 ) . send ( "Method not allowed." )
2019-11-18 18:39:17 -05:00
if ( ! req . body . ID ) return res . status ( 400 ) . send ( "No ID provided!" )
if ( ! req . body . accountID ) return res . status ( 400 ) . send ( "No account ID provided!" )
if ( ! req . body . password ) return res . status ( 400 ) . send ( "No password provided!" )
if ( ! req . body . like ) return res . status ( 400 ) . send ( "No like flag provided! (1=like, 0=dislike)" )
if ( ! req . body . type ) return res . status ( 400 ) . send ( "No type provided! (1=level, 2=comment, 3=profile" )
if ( ! req . body . extraID ) return res . status ( 400 ) . send ( "No extra ID provided! (this should be a level ID, account ID, or '0' for levels" )
2020-11-01 15:29:32 -05:00
let params = {
2019-11-18 18:39:17 -05:00
udid : '0' ,
uuid : '0' ,
rs : '8f0l0ClAN1'
2020-11-01 15:29:32 -05:00
}
2019-11-18 18:39:17 -05:00
params . itemID = req . body . ID . toString ( )
2021-01-18 21:54:18 -05:00
params . gjp = app . xor . encrypt ( req . body . password , 37526 )
2019-11-18 18:39:17 -05:00
params . accountID = req . body . accountID . toString ( )
params . like = req . body . like . toString ( )
params . special = req . body . extraID . toString ( )
params . type = req . body . type . toString ( )
let chk = params . special + params . itemID + params . like + params . type + params . rs + params . accountID + params . udid + params . uuid + "ysg6pUrtjn0J"
chk = sha1 ( chk )
2021-01-18 21:54:18 -05:00
chk = app . xor . encrypt ( chk , 58281 )
2019-11-18 18:39:17 -05:00
params . chk = chk
2021-01-18 21:54:18 -05:00
req . gdRequest ( 'likeGJItem211' , params , function ( err , resp , body ) {
2021-08-18 20:10:35 -04:00
if ( err ) return res . status ( 400 ) . send ( ` The Geometry Dash servers rejected your vote! Try again later, or make sure your username and password are entered correctly. Last worked: ${ app . timeSince ( req . id ) } ago. ` )
2021-01-18 21:54:18 -05:00
else app . trackSuccess ( req . id )
2019-11-18 18:39:17 -05:00
res . status ( 200 ) . send ( ( params . like == 1 ? 'Successfully liked!' : 'Successfully disliked!' ) + " (this will only take effect if this is your first time doing so)" )
} )
}