2019-12-25 16:20:32 -05:00
const request = require ( 'request' )
const XOR = require ( '../../classes/XOR.js' ) ;
const xor = new XOR ( ) ;
module . exports = async ( app , req , res , api ) => {
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!" )
2019-12-29 18:59:29 -05:00
if ( ! req . body . id ) return res . status ( 400 ) . send ( "No message ID(s) provided!" )
2019-12-25 16:20:32 -05:00
2020-09-29 21:42:18 -04:00
let params = app . gdParams ( {
2019-12-25 16:20:32 -05:00
accountID : req . body . accountID ,
gjp : xor . encrypt ( req . body . password , 37526 ) ,
messages : Array . isArray ( req . body . id ) ? req . body . id . map ( x => x . trim ( ) ) . join ( "," ) : req . body . id ,
2020-09-29 21:42:18 -04:00
} )
2019-12-25 16:20:32 -05:00
let deleted = params . messages . split ( "," ) . length
request . post ( app . endpoint + 'deleteGJMessages20.php' , {
2020-04-10 22:04:59 -04:00
form : params ,
headers : { 'x-forwarded-for' : req . headers [ 'x-real-ip' ] }
2019-12-25 16:20:32 -05:00
} , async function ( err , resp , body ) {
if ( body != 1 ) return res . status ( 400 ) . send ( "The Geometry Dash servers refused to delete the message! Make sure your username and password are entered correctly." )
else res . status ( 200 ) . send ( ` ${ deleted == 1 ? "1 message" : ` ${ deleted } messages ` } deleted! ` )
} )
}