2019-12-29 18:59:29 -05:00
module . exports = async ( app , req , res ) => {
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!" )
2021-01-18 21:54:18 -05:00
let params = {
2019-12-29 18:59:29 -05:00
accountID : req . body . accountID ,
targetAccountID : req . body . accountID ,
2021-01-18 21:54:18 -05:00
gjp : app . xor . encrypt ( req . body . password , 37526 ) ,
}
2019-12-29 18:59:29 -05:00
2021-01-18 21:54:18 -05:00
req . gdRequest ( 'getGJUserInfo20' , params , function ( err , resp , body ) {
2019-12-29 18:59:29 -05:00
2021-01-18 21:54:18 -05:00
if ( err || body == - 1 || body == - 2 || ! body ) return res . status ( 400 ) . send ( ` Error counting messages! Messages get blocked a lot so try again later, or make sure your username and password are entered correctly. Last worked: ${ app . timeSince ( req . id ) } ago. ` )
else app . trackSuccess ( req . id )
2019-12-29 18:59:29 -05:00
let count = app . parseResponse ( body ) [ 38 ]
if ( ! count ) return res . status ( 400 ) . send ( "Error fetching unread messages!" )
else res . status ( 200 ) . send ( count )
} )
}