Built motion from commit 1fd437e9.|2.6.19
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 74ac01f..418d910 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x58de=['name','User','agent','then','exports','models','define','VoiceChanSpy','length','VoiceExtension','bulkCreate','catch','destroy','lodash','util','bluebird','context','from-sip','%s%s','prefix','push','Set','format','CDR(type)=%s','record','merge','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','password','ChanSpy','options','join','StopMixMonitor','concat','internal'];(function(_0x185334,_0x4630ac){var _0xf2e59a=function(_0x3cc497){while(--_0x3cc497){_0x185334['push'](_0x185334['shift']());}};_0xf2e59a(++_0x4630ac);}(_0x58de,0x12d));var _0xe58d=function(_0x33f3fc,_0x2eaf31){_0x33f3fc=_0x33f3fc-0x0;var _0x156e09=_0x58de[_0x33f3fc];return _0x156e09;};'use strict';var _=require(_0xe58d('0x0'));var util=require(_0xe58d('0x1'));var BPromise=require(_0xe58d('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0xddd1fc,_0x215c9c,_0x574566){var _0x3bcb9b=0x1;var _0x2e7e9c=[];var _0x3b8516={'context':_0x215c9c[_0xe58d('0x3')]||_0xe58d('0x4'),'exten':util['format'](_0xe58d('0x5'),_0xddd1fc[_0xe58d('0x6')],_0x574566),'type':'system','isApp':![],'ChanSpyId':_0xddd1fc['id'],'UserId':_0x215c9c['id']};_0x2e7e9c[_0xe58d('0x7')](_['merge']({'app':_0xe58d('0x8'),'appdata':util[_0xe58d('0x9')](_0xe58d('0xa'),'chanspy'),'priority':_0x3bcb9b++},_0x3b8516));if(_0xddd1fc[_0xe58d('0xb')]){_0x2e7e9c[_0xe58d('0x7')](_[_0xe58d('0xc')]({'app':_0xe58d('0xd'),'appdata':util[_0xe58d('0x9')](_0xe58d('0xe'),_0xddd1fc[_0xe58d('0xf')]),'priority':_0x3bcb9b++},_0x3b8516));}if(_0xddd1fc['auth']){_0x2e7e9c[_0xe58d('0x7')](_[_0xe58d('0xc')]({'app':'Authenticate','appdata':_0xddd1fc[_0xe58d('0x10')],'priority':_0x3bcb9b++},_0x3b8516));}_0x2e7e9c[_0xe58d('0x7')](_['merge']({'app':_0xe58d('0x11'),'appdata':util[_0xe58d('0x9')]('SIP/%s,%s',_0x215c9c['name'],_0xddd1fc[_0xe58d('0x12')]?_0xddd1fc[_0xe58d('0x12')][_0xe58d('0x13')](''):''),'priority':_0x3bcb9b++},_0x3b8516));if(_0xddd1fc[_0xe58d('0xb')]){_0x2e7e9c['push'](_[_0xe58d('0xc')]({'app':_0xe58d('0x14'),'priority':_0x3bcb9b++},_0x3b8516));}return _0x2e7e9c;};var getChanSpyApplications=function(_0x4d962a,_0x584b81){var _0x8dfaed=[];for(var _0x2d0d78=0x0,_0xec09e3=0x1;_0x2d0d78<_0x584b81['length'];_0x2d0d78++,_0xec09e3=0x1){_0x8dfaed=_0x8dfaed[_0xe58d('0x15')](getUserApplications(_0x4d962a,_0x584b81[_0x2d0d78],_0x584b81[_0x2d0d78][_0xe58d('0x16')]));if(_0x584b81[_0x2d0d78][_0xe58d('0x16')]!=_0x584b81[_0x2d0d78][_0xe58d('0x17')]){_0x8dfaed=_0x8dfaed[_0xe58d('0x15')](getUserApplications(_0x4d962a,_0x584b81[_0x2d0d78],_0x584b81[_0x2d0d78][_0xe58d('0x17')]));}}return _0x8dfaed;};var getChanSpyPromise=function(_0x49b509,_0x253910){return new BPromise(function(_0x1cb0c6,_0x50b940){return _0x49b509[_0xe58d('0x18')]['findAll']({'attributes':['id','name',_0xe58d('0x16')],'where':{'role':_0xe58d('0x19'),'chanspy':!![]},'raw':!![]})[_0xe58d('0x1a')](function(_0x109154){if(_0x109154){return _0x1cb0c6(getChanSpyApplications(_0x253910,_0x109154));}return _0x1cb0c6([]);})['catch'](function(_0x155ea6){_0x50b940(_0x155ea6);});});};module[_0xe58d('0x1b')]=function(_0x4b4124,_0x593c1b){var _0x374f77=_0x4b4124[_0xe58d('0x1c')];return _0x4b4124[_0xe58d('0x1d')](_0xe58d('0x1e'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x25be66,_0x511a43,_0x17bd06){return getChanSpyPromise(_0x374f77,_0x25be66)[_0xe58d('0x1a')](function(_0x50a9c5){if(_0x50a9c5&&_0x50a9c5[_0xe58d('0x1f')]){return _0x374f77[_0xe58d('0x20')][_0xe58d('0x21')](_0x50a9c5);}})[_0xe58d('0x1a')](function(){_0x17bd06();})[_0xe58d('0x22')](function(_0x27b914){_0x17bd06(_0x27b914);});},'afterUpdate':function(_0x3a6384,_0x3ce1c6,_0x3a713c){return _0x374f77['VoiceExtension'][_0xe58d('0x23')]({'where':{'ChanSpyId':_0x3a6384['id']}})['then'](function(){return getChanSpyPromise(_0x374f77,_0x3a6384);})['then'](function(_0x380aed){if(_0x380aed&&_0x380aed[_0xe58d('0x1f')]){return _0x374f77['VoiceExtension'][_0xe58d('0x21')](_0x380aed);}})['then'](function(){_0x3a713c();})[_0xe58d('0x22')](function(_0x2ebb9d){_0x3a713c(_0x2ebb9d);});},'afterDestroy':function(_0x597077,_0x5ea282,_0x2865bd){return _0x374f77['VoiceExtension']['destroy']({'where':{'ChanSpyId':_0x597077['id']}})[_0xe58d('0x1a')](function(){_0x2865bd();})[_0xe58d('0x22')](function(_0x116f29){_0x2865bd(_0x116f29);});}}});};
\ No newline at end of file
+var _0x393b=['push','merge','Set','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','ChanSpy','SIP/%s,%s','name','options','join','concat','internal','User','findAll','then','catch','exports','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','length','lodash','util','bluebird','./voiceChanSpy.attributes','from-sip','format','%s%s','prefix','system'];(function(_0x2d86f2,_0x5e1b5c){var _0x4d2124=function(_0x4b6c2f){while(--_0x4b6c2f){_0x2d86f2['push'](_0x2d86f2['shift']());}};_0x4d2124(++_0x5e1b5c);}(_0x393b,0xed));var _0xb393=function(_0x1416fc,_0x72e155){_0x1416fc=_0x1416fc-0x0;var _0x3a4b34=_0x393b[_0x1416fc];return _0x3a4b34;};'use strict';var _=require(_0xb393('0x0'));var util=require(_0xb393('0x1'));var BPromise=require(_0xb393('0x2'));var attributes=require(_0xb393('0x3'));var getUserApplications=function(_0x561d0f,_0x10d45e,_0xe9144b){var _0x1cb6ed=0x1;var _0x568266=[];var _0x3ea1c0={'context':_0x10d45e['context']||_0xb393('0x4'),'exten':util[_0xb393('0x5')](_0xb393('0x6'),_0x561d0f[_0xb393('0x7')],_0xe9144b),'type':_0xb393('0x8'),'isApp':![],'ChanSpyId':_0x561d0f['id'],'UserId':_0x10d45e['id']};_0x568266[_0xb393('0x9')](_[_0xb393('0xa')]({'app':_0xb393('0xb'),'appdata':util[_0xb393('0x5')](_0xb393('0xc'),_0xb393('0xd')),'priority':_0x1cb6ed++},_0x3ea1c0));if(_0x561d0f[_0xb393('0xe')]){_0x568266['push'](_[_0xb393('0xa')]({'app':_0xb393('0xf'),'appdata':util[_0xb393('0x5')](_0xb393('0x10'),_0x561d0f[_0xb393('0x11')]),'priority':_0x1cb6ed++},_0x3ea1c0));}if(_0x561d0f[_0xb393('0x12')]){_0x568266[_0xb393('0x9')](_['merge']({'app':_0xb393('0x13'),'appdata':_0x561d0f[_0xb393('0x14')],'priority':_0x1cb6ed++},_0x3ea1c0));}_0x568266[_0xb393('0x9')](_[_0xb393('0xa')]({'app':_0xb393('0x15'),'appdata':util['format'](_0xb393('0x16'),_0x10d45e[_0xb393('0x17')],_0x561d0f['options']?_0x561d0f[_0xb393('0x18')][_0xb393('0x19')](''):''),'priority':_0x1cb6ed++},_0x3ea1c0));if(_0x561d0f['record']){_0x568266[_0xb393('0x9')](_[_0xb393('0xa')]({'app':'StopMixMonitor','priority':_0x1cb6ed++},_0x3ea1c0));}return _0x568266;};var getChanSpyApplications=function(_0x5d230b,_0x167551){var _0x52ca03=[];for(var _0x206b88=0x0,_0x12e1df=0x1;_0x206b88<_0x167551['length'];_0x206b88++,_0x12e1df=0x1){_0x52ca03=_0x52ca03[_0xb393('0x1a')](getUserApplications(_0x5d230b,_0x167551[_0x206b88],_0x167551[_0x206b88][_0xb393('0x1b')]));if(_0x167551[_0x206b88][_0xb393('0x1b')]!=_0x167551[_0x206b88][_0xb393('0x17')]){_0x52ca03=_0x52ca03[_0xb393('0x1a')](getUserApplications(_0x5d230b,_0x167551[_0x206b88],_0x167551[_0x206b88]['name']));}}return _0x52ca03;};var getChanSpyPromise=function(_0x49f713,_0x1919fc){return new BPromise(function(_0x153f55,_0x4fb89c){return _0x49f713[_0xb393('0x1c')][_0xb393('0x1d')]({'attributes':['id',_0xb393('0x17'),_0xb393('0x1b')],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0xb393('0x1e')](function(_0x2aadbe){if(_0x2aadbe){return _0x153f55(getChanSpyApplications(_0x1919fc,_0x2aadbe));}return _0x153f55([]);})[_0xb393('0x1f')](function(_0x3dbb4f){_0x4fb89c(_0x3dbb4f);});});};module[_0xb393('0x20')]=function(_0x1c5a6b,_0x5e51a3){var _0x3fdb71=_0x1c5a6b[_0xb393('0x21')];return _0x1c5a6b[_0xb393('0x22')](_0xb393('0x23'),attributes,{'tableName':_0xb393('0x24'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x3add5c,_0x7532f,_0x405721){return getChanSpyPromise(_0x3fdb71,_0x3add5c)[_0xb393('0x1e')](function(_0x28e3c8){if(_0x28e3c8&&_0x28e3c8['length']){return _0x3fdb71[_0xb393('0x25')][_0xb393('0x26')](_0x28e3c8);}})['then'](function(){_0x405721();})['catch'](function(_0x4557d8){_0x405721(_0x4557d8);});},'afterUpdate':function(_0x510908,_0x3c5f6b,_0x366215){return _0x3fdb71['VoiceExtension'][_0xb393('0x27')]({'where':{'ChanSpyId':_0x510908['id']}})[_0xb393('0x1e')](function(){return getChanSpyPromise(_0x3fdb71,_0x510908);})[_0xb393('0x1e')](function(_0x4527df){if(_0x4527df&&_0x4527df[_0xb393('0x28')]){return _0x3fdb71[_0xb393('0x25')][_0xb393('0x26')](_0x4527df);}})[_0xb393('0x1e')](function(){_0x366215();})[_0xb393('0x1f')](function(_0x232a5f){_0x366215(_0x232a5f);});},'afterDestroy':function(_0x452d84,_0x377cad,_0xd2f568){return _0x3fdb71[_0xb393('0x25')]['destroy']({'where':{'ChanSpyId':_0x452d84['id']}})['then'](function(){_0xd2f568();})[_0xb393('0x1f')](function(_0x68978){_0xd2f568(_0x68978);});}}});};
\ No newline at end of file