@@ -52,8 +52,8 @@ export default async function ChangeName(req: Request<any>, res: Response<any>)
5252 log ( `[!${ req . body . area } , ${ ip } ] Wrong phone number` , `WARNING` , __filename ) ;
5353 return ;
5454 }
55- req . body . newName = req . body . newName . trim ( ) ;
56- if ( req . body . newName == `` ) {
55+ req . body . newName = sanitizeString ( req . body . newName ) ;
56+ if ( req . body . newName == `` || req . body . newName . length > 50 || req . body . newName . length < 3 ) {
5757 res . status ( 400 ) . send ( { message : `Wrong newName` , OK : false } ) ;
5858 log ( `[!${ req . body . area } , ${ ip } ] Wrong newName` , `WARNING` , __filename ) ;
5959 return ;
@@ -68,9 +68,10 @@ export default async function ChangeName(req: Request<any>, res: Response<any>)
6868 return ;
6969 }
7070
71- req . body . newName = sanitizeString ( req . body . newName ) ;
72-
73- const change = await Caller . updateOne ( { phone : phone , area : { $eq : req . body . area } } , { name : req . body . newName } ) ;
71+ const change = await Caller . updateOne (
72+ { phone : phone , campaigns : { $in : area . campaignList } } ,
73+ { name : req . body . newName }
74+ ) ;
7475 if ( change . matchedCount != 1 ) {
7576 res . status ( 400 ) . send ( { message : `Caller not found` , OK : false } ) ;
7677 log ( `[${ ip } , ${ req . body . area } ] Caller not found` , `WARNING` , __filename ) ;
0 commit comments