2f0c6c691a53b86821c4e555e285b477d26b192f
[motion.git] / server / api / sms_room / sms_room.controller.js
1 var _0x622a=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x53\x6D\x73\x52\x6F\x6F\x6D","\x55\x73\x65\x72","\x53\x6D\x73\x4D\x65\x73\x73\x61\x67\x65","\x53\x6D\x73\x41\x63\x63\x6F\x75\x6E\x74","\x53\x6D\x73\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x53\x6D\x73\x51\x75\x65\x75\x65","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x64\x65\x66\x61\x75\x6C\x74","\x61\x67\x65\x6E\x74","\x69\x64","\x75\x73\x65\x72","\x73\x63\x6F\x70\x65","\x72\x6F\x6C\x65","\x64\x65\x73\x63\x72\x69\x62\x65","\x6D\x61\x70","\x67\x65\x74\x53\x6D\x73\x51\x75\x65\x75\x65\x73\x49\x64\x42\x79\x55\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x70\x65\x6E\x64\x69\x6E\x67","\x50\x45\x4E\x44\x49\x4E\x47","\x64\x61\x79","\x73\x74\x61\x72\x74\x4F\x66","\x6D\x65\x72\x67\x65","\x63\x6F\x75\x6E\x74","\x61\x6C\x6C","\x6E\x65\x77","\x4E\x45\x57","\x6F\x70\x65\x6E","\x4F\x50\x45\x4E","\x63\x6C\x6F\x73\x65\x64","\x43\x4C\x4F\x53\x45\x44","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x70\x61\x72\x61\x6D\x73","\x73\x68\x6F\x77\x41\x67\x65\x6E\x74\x73","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x67\x65\x74\x55\x73\x65\x72\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x4D\x65\x73\x73\x61\x67\x65","\x67\x65\x74\x53\x6D\x73\x52\x6F\x6F\x6D","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x63\x72\x65\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x55\x73\x65\x72\x49\x64","\x53\x6D\x73\x52\x6F\x6F\x6D\x49\x64","\x75\x70\x64\x61\x74\x65","\x73\x61\x76\x65","\x75\x70\x64\x61\x74\x65\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x73\x65\x74\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73","\x67\x65\x74\x44\x61\x73\x68\x62\x6F\x61\x72\x64\x56\x61\x6C\x75\x65\x73","\x6B\x65\x79\x42\x79","\x6D\x61\x70\x56\x61\x6C\x75\x65\x73","\x53\x45\x4C\x45\x43\x54\x20\x4C\x4F\x57\x45\x52\x28\x73\x74\x61\x74\x75\x73\x29\x20\x41\x53\x20\x73\x74\x61\x74\x75\x73\x2C\x20\x43\x4F\x55\x4E\x54\x28\x69\x64\x29\x20\x41\x53\x20\x63\x6F\x75\x6E\x74\x20\x46\x52\x4F\x4D\x20\x73\x6D\x73\x5F\x72\x6F\x6F\x6D\x73\x20\x47\x52\x4F\x55\x50\x20\x42\x59\x20\x73\x74\x61\x74\x75\x73","\x53\x45\x4C\x45\x43\x54","\x51\x75\x65\x72\x79\x54\x79\x70\x65\x73","\x75\x70\x64\x61\x74\x65\x50\x61\x74\x63\x68","\x2C","\x73\x70\x6C\x69\x74"];_0x622a[0];var _=require(_0x622a[1]);var Util=require(_0x622a[2]);var moment=require(_0x622a[3]);var sequelize=require(_0x622a[5])[_0x622a[4]];var logger=require(_0x622a[7])(_0x622a[6]);var SmsRoom=require(_0x622a[5])[_0x622a[8]];var User=require(_0x622a[5])[_0x622a[9]];var SmsMessage=require(_0x622a[5])[_0x622a[10]];var SmsAccount=require(_0x622a[5])[_0x622a[11]];var User=require(_0x622a[5])[_0x622a[9]];var SmsApplication=require(_0x622a[5])[_0x622a[12]];var SmsQueue=require(_0x622a[5])[_0x622a[13]];function handleError(_0x4e29xd,_0x4e29xe){logger[_0x622a[15]](_0x4e29xe[_0x622a[14]]);return _0x4e29xd[_0x622a[17]](500)[_0x622a[16]](_0x4e29xe)}exports[_0x622a[18]]= function(_0x4e29xf,_0x4e29xd){switch(_0x4e29xf[_0x622a[27]][_0x622a[29]]){case _0x622a[25]:return SmsRoom[_0x622a[28]](_0x622a[24],{method:[_0x622a[25],_0x4e29xf[_0x622a[27]][_0x622a[26]]]})[_0x622a[23]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]]))[_0x622a[20]](function(_0x4e29x10){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]](_0x4e29x10)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)});default:return SmsRoom[_0x622a[28]](_0x622a[24])[_0x622a[23]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]]))[_0x622a[20]](function(_0x4e29x10){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]](_0x4e29x10)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})}};exports[_0x622a[30]]= function(_0x4e29xf,_0x4e29xd){return SmsRoom[_0x622a[30]]()[_0x622a[20]](function(_0x4e29x11){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]](_0x4e29x11)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};function getSmsQueues(_0x4e29x13){return function(){switch(_0x4e29x13[_0x622a[29]]){case _0x622a[27]:return User[_0x622a[33]](_0x4e29x13[_0x622a[26]],{attributes:[_0x622a[26]]})[_0x622a[20]](Util[_0x622a[32]]({},{attributes:[_0x622a[26]],include:[{raw:true,model:User,attributes:[_0x622a[26]]}]}))[_0x622a[20]](function(_0x4e29x14){return {include:{model:SmsAccount,include:{model:SmsApplication,include:{model:SmsQueue,where:{id:_[_0x622a[31]](_0x4e29x14,_0x622a[26])}}}}}});default:return {}}}}exports[_0x622a[34]]= function(_0x4e29xf,_0x4e29xd){return Promise[_0x622a[40]]([])[_0x622a[20]](getSmsQueues(_0x4e29xf[_0x622a[27]]))[_0x622a[20]](function(_0x4e29x16){return SmsRoom[_0x622a[39]](_[_0x622a[38]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]],{status:_0x622a[35],updatedAt:{$gte:moment()[_0x622a[37]](_0x622a[36])}}),_0x4e29x16))})[_0x622a[20]](function(_0x4e29x15){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]]({value:_0x4e29x15})})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[41]]= function(_0x4e29xf,_0x4e29xd){return Promise[_0x622a[40]]([])[_0x622a[20]](getSmsQueues(_0x4e29xf[_0x622a[27]]))[_0x622a[20]](function(_0x4e29x16){return SmsRoom[_0x622a[39]](_[_0x622a[38]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]],{status:_0x622a[42],updatedAt:{$gte:moment()[_0x622a[37]](_0x622a[36])}}),_0x4e29x16))})[_0x622a[20]](function(_0x4e29x15){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]]({value:_0x4e29x15})})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[43]]= function(_0x4e29xf,_0x4e29xd){return Promise[_0x622a[40]]([])[_0x622a[20]](getSmsQueues(_0x4e29xf[_0x622a[27]]))[_0x622a[20]](function(_0x4e29x16){return SmsRoom[_0x622a[39]](_[_0x622a[38]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]],{status:_0x622a[44],updatedAt:{$gte:moment()[_0x622a[37]](_0x622a[36])}}),_0x4e29x16))})[_0x622a[20]](function(_0x4e29x15){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]]({value:_0x4e29x15})})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[45]]= function(_0x4e29xf,_0x4e29xd){return Promise[_0x622a[40]]([])[_0x622a[20]](getSmsQueues(_0x4e29xf[_0x622a[27]]))[_0x622a[20]](function(_0x4e29x16){return SmsRoom[_0x622a[39]](_[_0x622a[38]](Util[_0x622a[22]](_0x4e29xf[_0x622a[21]],{status:_0x622a[46],updatedAt:{$gte:moment()[_0x622a[37]](_0x622a[36])}}),_0x4e29x16))})[_0x622a[20]](function(_0x4e29x15){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]]({value:_0x4e29x15})})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[47]]= function(_0x4e29xf,_0x4e29xd){return SmsRoom[_0x622a[28]](_0x622a[24])[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x17){if(!_0x4e29x17){return _0x4e29xd[_0x622a[48]](404)};return _0x4e29xd[_0x622a[16]](_0x4e29x17)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[50]]= function(_0x4e29xf,_0x4e29xd,_0x4e29x18){return SmsRoom[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x17){if(!_0x4e29x17){return _0x4e29xd[_0x622a[48]](404)};return _0x4e29x17[_0x622a[55]]({attributes:[_0x622a[26],_0x622a[51],_0x622a[52],_0x622a[53],_0x622a[29],_0x622a[54]]})})[_0x622a[20]](function(_0x4e29x19){return _0x4e29xd[_0x622a[16]](_0x4e29x19)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[56]]= function(_0x4e29xf,_0x4e29xd,_0x4e29x18){return SmsMessage[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x1b){return _0x4e29x1b[_0x622a[57]]({include:[{model:SmsAccount},{model:SmsMessage,include:[{model:User,attributes:[_0x622a[26],_0x622a[51],_0x622a[52],_0x622a[53]]}]},{model:User,attributes:[_0x622a[26],_0x622a[51],_0x622a[52],_0x622a[53]]}]})})[_0x622a[20]](function(_0x4e29x1a){return _0x4e29xd[_0x622a[16]](_0x4e29x1a)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[58]]= function(_0x4e29xf,_0x4e29xd){return SmsRoom[_0x622a[58]](_0x4e29xf[_0x622a[59]])[_0x622a[20]](function(_0x4e29x1c){return _0x4e29xd[_0x622a[17]](201)[_0x622a[16]](_0x4e29x1c)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[60]]= function(_0x4e29xf,_0x4e29xd,_0x4e29x18){_0x4e29xf[_0x622a[59]][_0x622a[61]]= _0x4e29xf[_0x622a[27]][_0x622a[26]];_0x4e29xf[_0x622a[59]][_0x622a[62]]= _0x4e29xf[_0x622a[49]][_0x622a[26]];return SmsMessage[_0x622a[58]](_0x4e29xf[_0x622a[59]])[_0x622a[20]](function(_0x4e29x1c){return _0x4e29xd[_0x622a[17]](201)[_0x622a[16]](_0x4e29x1c)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[63]]= function(_0x4e29xf,_0x4e29xd){if(_0x4e29xf[_0x622a[59]][_0x622a[26]]){delete _0x4e29xf[_0x622a[59]][_0x622a[26]]};return SmsRoom[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x17){if(!_0x4e29x17){return _0x4e29xd[_0x622a[48]](404)};var _0x4e29x1d=_[_0x622a[38]](_0x4e29x17,_0x4e29xf[_0x622a[59]]);return _0x4e29x1d[_0x622a[64]]()})[_0x622a[20]](function(_0x4e29x17){return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]](_0x4e29x17)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[65]]= function(_0x4e29xf,_0x4e29xd,_0x4e29x18){return SmsRoom[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x17){if(!_0x4e29x17){return _0x4e29xd[_0x622a[48]](404)};return _0x4e29x17[_0x622a[67]](_0x4e29xf[_0x622a[59]][_0x622a[66]],{individualHooks:true})})[_0x622a[20]](function(){return _0x4e29xd[_0x622a[48]](200)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[68]]= function(_0x4e29xf,_0x4e29xd){return SmsRoom[_0x622a[33]](_0x4e29xf[_0x622a[49]][_0x622a[26]])[_0x622a[20]](function(_0x4e29x17){if(!_0x4e29x17){return _0x4e29xd[_0x622a[48]](404)};return _0x4e29x17[_0x622a[68]]()})[_0x622a[20]](function(){return _0x4e29xd[_0x622a[48]](204)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[69]]= function(_0x4e29xf,_0x4e29xd){return SmsRoom[_0x622a[68]]({where:{id:_0x4e29xf[_0x622a[21]][_0x622a[70]]},individualHooks:true})[_0x622a[20]](function(){return _0x4e29xd[_0x622a[48]](200)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[71]]= function(_0x4e29xf,_0x4e29xd){return sequelize[_0x622a[21]](_0x622a[74],{type:sequelize[_0x622a[76]][_0x622a[75]]})[_0x622a[20]](function(_0x4e29x1e){var _0x4e29x1f=_[_0x622a[38]]({new:0,open:0,pending:0,closed:0},_[_0x622a[73]](_[_0x622a[72]](_0x4e29x1e,_0x622a[17]),_0x622a[39]));return _0x4e29xd[_0x622a[17]](200)[_0x622a[16]](_0x4e29x1f)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})};exports[_0x622a[77]]= function(_0x4e29xf,_0x4e29xd,_0x4e29x18){var _0x4e29x20={where:{id:_0x4e29xf[_0x622a[49]][_0x622a[26]][_0x622a[79]](_0x622a[78])},user:_0x4e29xf[_0x622a[27]],individualHooks:true};return SmsRoom[_0x622a[63]](_0x4e29xf[_0x622a[59]],_0x4e29x20)[_0x622a[20]](function(_0x4e29x21){if(!_0x4e29x21){return _0x4e29xd[_0x622a[48]](404)};return _0x4e29x21})[_0x622a[20]](function(_0x4e29x21){return _0x4e29xd[_0x622a[48]](200)})[_0x622a[19]](function(_0x4e29xe){return handleError(_0x4e29xd,_0x4e29xe)})}