Built motion from commit db94841.|2.5.3
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index b957009..1f6da77 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0b2e=['findAll','internal','agent','catch','models','define','VoiceChanSpy','voice_chanspy','then','VoiceExtension','bulkCreate','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','prefix','push','chanspy','merge','MixMonitor','${UNIQUEID}.%s,ab','recordingFormat','auth','Authenticate','ChanSpy','SIP/%s,%s','options','StopMixMonitor','length','concat','name','User'];(function(_0x5a63a4,_0x6407ab){var _0x47d76f=function(_0x100a08){while(--_0x100a08){_0x5a63a4['push'](_0x5a63a4['shift']());}};_0x47d76f(++_0x6407ab);}(_0x0b2e,0x150));var _0xe0b2=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0b2e[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xe0b2('0x0'));var util=require(_0xe0b2('0x1'));var BPromise=require(_0xe0b2('0x2'));var attributes=require(_0xe0b2('0x3'));var getUserApplications=function(_0x237e3f,_0x1492b6,_0x456716){var _0x4a7820=0x1;var _0x14f2c8=[];var _0x47e3d9={'context':_0x1492b6[_0xe0b2('0x4')]||_0xe0b2('0x5'),'exten':util[_0xe0b2('0x6')]('%s%s',_0x237e3f[_0xe0b2('0x7')],_0x456716),'type':'system','isApp':![],'ChanSpyId':_0x237e3f['id'],'UserId':_0x1492b6['id']};_0x14f2c8[_0xe0b2('0x8')](_['merge']({'app':'Set','appdata':util[_0xe0b2('0x6')]('CDR(type)=%s',_0xe0b2('0x9')),'priority':_0x4a7820++},_0x47e3d9));if(_0x237e3f['record']){_0x14f2c8[_0xe0b2('0x8')](_[_0xe0b2('0xa')]({'app':_0xe0b2('0xb'),'appdata':util[_0xe0b2('0x6')](_0xe0b2('0xc'),_0x237e3f[_0xe0b2('0xd')]),'priority':_0x4a7820++},_0x47e3d9));}if(_0x237e3f[_0xe0b2('0xe')]){_0x14f2c8[_0xe0b2('0x8')](_[_0xe0b2('0xa')]({'app':_0xe0b2('0xf'),'appdata':_0x237e3f['password'],'priority':_0x4a7820++},_0x47e3d9));}_0x14f2c8[_0xe0b2('0x8')](_[_0xe0b2('0xa')]({'app':_0xe0b2('0x10'),'appdata':util[_0xe0b2('0x6')](_0xe0b2('0x11'),_0x1492b6['name'],_0x237e3f['options']?_0x237e3f[_0xe0b2('0x12')]['join'](''):''),'priority':_0x4a7820++},_0x47e3d9));if(_0x237e3f['record']){_0x14f2c8[_0xe0b2('0x8')](_[_0xe0b2('0xa')]({'app':_0xe0b2('0x13'),'priority':_0x4a7820++},_0x47e3d9));}return _0x14f2c8;};var getChanSpyApplications=function(_0x2059e3,_0xe3d81b){var _0x269d30=[];for(var _0x34299c=0x0,_0x3f1078=0x1;_0x34299c<_0xe3d81b[_0xe0b2('0x14')];_0x34299c++,_0x3f1078=0x1){_0x269d30=_0x269d30[_0xe0b2('0x15')](getUserApplications(_0x2059e3,_0xe3d81b[_0x34299c],_0xe3d81b[_0x34299c]['internal']));if(_0xe3d81b[_0x34299c]['internal']!=_0xe3d81b[_0x34299c]['name']){_0x269d30=_0x269d30['concat'](getUserApplications(_0x2059e3,_0xe3d81b[_0x34299c],_0xe3d81b[_0x34299c][_0xe0b2('0x16')]));}}return _0x269d30;};var getChanSpyPromise=function(_0x4b8d68,_0x3965d7){return new BPromise(function(_0x1dd6a4,_0x5f3d16){return _0x4b8d68[_0xe0b2('0x17')][_0xe0b2('0x18')]({'attributes':['id','name',_0xe0b2('0x19')],'where':{'role':_0xe0b2('0x1a'),'chanspy':!![]},'raw':!![]})['then'](function(_0x136f11){if(_0x136f11){return _0x1dd6a4(getChanSpyApplications(_0x3965d7,_0x136f11));}return _0x1dd6a4([]);})[_0xe0b2('0x1b')](function(_0x3bd394){_0x5f3d16(_0x3bd394);});});};module['exports']=function(_0x2f351b,_0x425916){var _0x540ee2=_0x2f351b[_0xe0b2('0x1c')];return _0x2f351b[_0xe0b2('0x1d')](_0xe0b2('0x1e'),attributes,{'tableName':_0xe0b2('0x1f'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x141556,_0x2898da,_0x35169a){return getChanSpyPromise(_0x540ee2,_0x141556)[_0xe0b2('0x20')](function(_0x1eba41){if(_0x1eba41&&_0x1eba41[_0xe0b2('0x14')]){return _0x540ee2[_0xe0b2('0x21')]['bulkCreate'](_0x1eba41);}})[_0xe0b2('0x20')](function(){_0x35169a();})[_0xe0b2('0x1b')](function(_0x3d3971){_0x35169a(_0x3d3971);});},'afterUpdate':function(_0x22bc69,_0x1b984f,_0x3748b8){return _0x540ee2[_0xe0b2('0x21')]['destroy']({'where':{'ChanSpyId':_0x22bc69['id']}})[_0xe0b2('0x20')](function(){return getChanSpyPromise(_0x540ee2,_0x22bc69);})[_0xe0b2('0x20')](function(_0x3b2a54){if(_0x3b2a54&&_0x3b2a54[_0xe0b2('0x14')]){return _0x540ee2[_0xe0b2('0x21')][_0xe0b2('0x22')](_0x3b2a54);}})[_0xe0b2('0x20')](function(){_0x3748b8();})[_0xe0b2('0x1b')](function(_0xe2d551){_0x3748b8(_0xe2d551);});},'afterDestroy':function(_0x3b31b1,_0x298d59,_0x2eec4c){return _0x540ee2['VoiceExtension'][_0xe0b2('0x23')]({'where':{'ChanSpyId':_0x3b31b1['id']}})[_0xe0b2('0x20')](function(){_0x2eec4c();})['catch'](function(_0x1ab918){_0x2eec4c(_0x1ab918);});}}});};
\ No newline at end of file
+var _0x331c=['name','findAll','agent','catch','models','then','bulkCreate','VoiceExtension','destroy','lodash','bluebird','context','from-sip','%s%s','prefix','push','merge','Set','format','chanspy','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','password','ChanSpy','SIP/%s,%s','options','record','StopMixMonitor','length','concat','internal'];(function(_0x2d2615,_0x37d1a7){var _0x8d7ddc=function(_0x523af0){while(--_0x523af0){_0x2d2615['push'](_0x2d2615['shift']());}};_0x8d7ddc(++_0x37d1a7);}(_0x331c,0xf0));var _0xc331=function(_0x411add,_0x1aed38){_0x411add=_0x411add-0x0;var _0x238242=_0x331c[_0x411add];return _0x238242;};'use strict';var _=require(_0xc331('0x0'));var util=require('util');var BPromise=require(_0xc331('0x1'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x4ed262,_0x15f272,_0x4f695b){var _0x4bcd1b=0x1;var _0x2eaa9d=[];var _0x54d8ca={'context':_0x15f272[_0xc331('0x2')]||_0xc331('0x3'),'exten':util['format'](_0xc331('0x4'),_0x4ed262[_0xc331('0x5')],_0x4f695b),'type':'system','isApp':![],'ChanSpyId':_0x4ed262['id'],'UserId':_0x15f272['id']};_0x2eaa9d[_0xc331('0x6')](_[_0xc331('0x7')]({'app':_0xc331('0x8'),'appdata':util[_0xc331('0x9')]('CDR(type)=%s',_0xc331('0xa')),'priority':_0x4bcd1b++},_0x54d8ca));if(_0x4ed262['record']){_0x2eaa9d[_0xc331('0x6')](_[_0xc331('0x7')]({'app':_0xc331('0xb'),'appdata':util[_0xc331('0x9')](_0xc331('0xc'),_0x4ed262[_0xc331('0xd')]),'priority':_0x4bcd1b++},_0x54d8ca));}if(_0x4ed262[_0xc331('0xe')]){_0x2eaa9d[_0xc331('0x6')](_[_0xc331('0x7')]({'app':'Authenticate','appdata':_0x4ed262[_0xc331('0xf')],'priority':_0x4bcd1b++},_0x54d8ca));}_0x2eaa9d[_0xc331('0x6')](_[_0xc331('0x7')]({'app':_0xc331('0x10'),'appdata':util[_0xc331('0x9')](_0xc331('0x11'),_0x15f272['name'],_0x4ed262[_0xc331('0x12')]?_0x4ed262[_0xc331('0x12')]['join'](''):''),'priority':_0x4bcd1b++},_0x54d8ca));if(_0x4ed262[_0xc331('0x13')]){_0x2eaa9d[_0xc331('0x6')](_[_0xc331('0x7')]({'app':_0xc331('0x14'),'priority':_0x4bcd1b++},_0x54d8ca));}return _0x2eaa9d;};var getChanSpyApplications=function(_0x5265b5,_0x5808f6){var _0x108485=[];for(var _0x18e6df=0x0,_0x4b4006=0x1;_0x18e6df<_0x5808f6[_0xc331('0x15')];_0x18e6df++,_0x4b4006=0x1){_0x108485=_0x108485[_0xc331('0x16')](getUserApplications(_0x5265b5,_0x5808f6[_0x18e6df],_0x5808f6[_0x18e6df]['internal']));if(_0x5808f6[_0x18e6df][_0xc331('0x17')]!=_0x5808f6[_0x18e6df][_0xc331('0x18')]){_0x108485=_0x108485['concat'](getUserApplications(_0x5265b5,_0x5808f6[_0x18e6df],_0x5808f6[_0x18e6df][_0xc331('0x18')]));}}return _0x108485;};var getChanSpyPromise=function(_0x36040d,_0x19ed1f){return new BPromise(function(_0x176e38,_0x34ccdd){return _0x36040d['User'][_0xc331('0x19')]({'attributes':['id','name',_0xc331('0x17')],'where':{'role':_0xc331('0x1a'),'chanspy':!![]},'raw':!![]})['then'](function(_0x2a0324){if(_0x2a0324){return _0x176e38(getChanSpyApplications(_0x19ed1f,_0x2a0324));}return _0x176e38([]);})[_0xc331('0x1b')](function(_0x416019){_0x34ccdd(_0x416019);});});};module['exports']=function(_0x176383,_0x466252){var _0x5210c0=_0x176383[_0xc331('0x1c')];return _0x176383['define']('VoiceChanSpy',attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x32839f,_0x5ddcf9,_0x3865f1){return getChanSpyPromise(_0x5210c0,_0x32839f)[_0xc331('0x1d')](function(_0x16ea9f){if(_0x16ea9f&&_0x16ea9f[_0xc331('0x15')]){return _0x5210c0['VoiceExtension'][_0xc331('0x1e')](_0x16ea9f);}})['then'](function(){_0x3865f1();})['catch'](function(_0x55338e){_0x3865f1(_0x55338e);});},'afterUpdate':function(_0x253687,_0x5438e9,_0x38c1e7){return _0x5210c0[_0xc331('0x1f')][_0xc331('0x20')]({'where':{'ChanSpyId':_0x253687['id']}})[_0xc331('0x1d')](function(){return getChanSpyPromise(_0x5210c0,_0x253687);})[_0xc331('0x1d')](function(_0x3dc48a){if(_0x3dc48a&&_0x3dc48a[_0xc331('0x15')]){return _0x5210c0[_0xc331('0x1f')][_0xc331('0x1e')](_0x3dc48a);}})[_0xc331('0x1d')](function(){_0x38c1e7();})['catch'](function(_0x8f656b){_0x38c1e7(_0x8f656b);});},'afterDestroy':function(_0x20042a,_0x5d49f7,_0x3dccd8){return _0x5210c0['VoiceExtension'][_0xc331('0x20')]({'where':{'ChanSpyId':_0x20042a['id']}})['then'](function(){_0x3dccd8();})[_0xc331('0x1b')](function(_0x52dd47){_0x3dccd8(_0x52dd47);});}}});};
\ No newline at end of file