Built motion from commit 44b1f254.|2.6.26
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 6942fa4..9c8bd78 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcf15=['./voiceChanSpy.attributes','context','format','%s%s','push','merge','CDR(type)=%s','chanspy','MixMonitor','recordingFormat','auth','Authenticate','password','ChanSpy','options','join','StopMixMonitor','length','internal','name','concat','findAll','then','catch','exports','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','lodash'];(function(_0x2c26a0,_0x2b9577){var _0x3e26d2=function(_0xcd6fc5){while(--_0xcd6fc5){_0x2c26a0['push'](_0x2c26a0['shift']());}};_0x3e26d2(++_0x2b9577);}(_0xcf15,0x1ee));var _0x5cf1=function(_0x2fd405,_0x3cf166){_0x2fd405=_0x2fd405-0x0;var _0x2f0d58=_0xcf15[_0x2fd405];return _0x2f0d58;};'use strict';var _=require(_0x5cf1('0x0'));var util=require('util');var BPromise=require('bluebird');var attributes=require(_0x5cf1('0x1'));var getUserApplications=function(_0x4e513e,_0x100aed,_0x566087){var _0x377bb8=0x1;var _0x13a9d3=[];var _0x474b13={'context':_0x100aed[_0x5cf1('0x2')]||'from-sip','exten':util[_0x5cf1('0x3')](_0x5cf1('0x4'),_0x4e513e['prefix'],_0x566087),'type':'system','isApp':![],'ChanSpyId':_0x4e513e['id'],'UserId':_0x100aed['id']};_0x13a9d3[_0x5cf1('0x5')](_[_0x5cf1('0x6')]({'app':'Set','appdata':util[_0x5cf1('0x3')](_0x5cf1('0x7'),_0x5cf1('0x8')),'priority':_0x377bb8++},_0x474b13));if(_0x4e513e['record']){_0x13a9d3[_0x5cf1('0x5')](_[_0x5cf1('0x6')]({'app':_0x5cf1('0x9'),'appdata':util['format']('${UNIQUEID}.%s,a',_0x4e513e[_0x5cf1('0xa')]),'priority':_0x377bb8++},_0x474b13));}if(_0x4e513e[_0x5cf1('0xb')]){_0x13a9d3[_0x5cf1('0x5')](_[_0x5cf1('0x6')]({'app':_0x5cf1('0xc'),'appdata':_0x4e513e[_0x5cf1('0xd')],'priority':_0x377bb8++},_0x474b13));}_0x13a9d3[_0x5cf1('0x5')](_['merge']({'app':_0x5cf1('0xe'),'appdata':util[_0x5cf1('0x3')]('SIP/%s,%s',_0x100aed['name'],_0x4e513e[_0x5cf1('0xf')]?_0x4e513e[_0x5cf1('0xf')][_0x5cf1('0x10')](''):''),'priority':_0x377bb8++},_0x474b13));if(_0x4e513e['record']){_0x13a9d3['push'](_[_0x5cf1('0x6')]({'app':_0x5cf1('0x11'),'priority':_0x377bb8++},_0x474b13));}return _0x13a9d3;};var getChanSpyApplications=function(_0x55c92a,_0x154bf3){var _0x5b8686=[];for(var _0xcbe847=0x0,_0x3f448d=0x1;_0xcbe847<_0x154bf3[_0x5cf1('0x12')];_0xcbe847++,_0x3f448d=0x1){_0x5b8686=_0x5b8686['concat'](getUserApplications(_0x55c92a,_0x154bf3[_0xcbe847],_0x154bf3[_0xcbe847][_0x5cf1('0x13')]));if(_0x154bf3[_0xcbe847]['internal']!=_0x154bf3[_0xcbe847][_0x5cf1('0x14')]){_0x5b8686=_0x5b8686[_0x5cf1('0x15')](getUserApplications(_0x55c92a,_0x154bf3[_0xcbe847],_0x154bf3[_0xcbe847][_0x5cf1('0x14')]));}}return _0x5b8686;};var getChanSpyPromise=function(_0x364c2c,_0x476451){return new BPromise(function(_0x32a076,_0x375dd2){return _0x364c2c['User'][_0x5cf1('0x16')]({'attributes':['id',_0x5cf1('0x14'),_0x5cf1('0x13')],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x5cf1('0x17')](function(_0x379ca6){if(_0x379ca6){return _0x32a076(getChanSpyApplications(_0x476451,_0x379ca6));}return _0x32a076([]);})[_0x5cf1('0x18')](function(_0x43baab){_0x375dd2(_0x43baab);});});};module[_0x5cf1('0x19')]=function(_0x21b6b0,_0x47a6ce){var _0x3b9ef6=_0x21b6b0[_0x5cf1('0x1a')];return _0x21b6b0[_0x5cf1('0x1b')](_0x5cf1('0x1c'),attributes,{'tableName':_0x5cf1('0x1d'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1e8be4,_0xd03213,_0x46ed0d){return getChanSpyPromise(_0x3b9ef6,_0x1e8be4)[_0x5cf1('0x17')](function(_0x43163d){if(_0x43163d&&_0x43163d[_0x5cf1('0x12')]){return _0x3b9ef6[_0x5cf1('0x1e')][_0x5cf1('0x1f')](_0x43163d);}})[_0x5cf1('0x17')](function(){_0x46ed0d();})[_0x5cf1('0x18')](function(_0x2c7401){_0x46ed0d(_0x2c7401);});},'afterUpdate':function(_0x38a244,_0x2f0f73,_0x96689f){return _0x3b9ef6[_0x5cf1('0x1e')][_0x5cf1('0x20')]({'where':{'ChanSpyId':_0x38a244['id']}})[_0x5cf1('0x17')](function(){return getChanSpyPromise(_0x3b9ef6,_0x38a244);})['then'](function(_0x503a97){if(_0x503a97&&_0x503a97[_0x5cf1('0x12')]){return _0x3b9ef6['VoiceExtension'][_0x5cf1('0x1f')](_0x503a97);}})[_0x5cf1('0x17')](function(){_0x96689f();})[_0x5cf1('0x18')](function(_0x4edb78){_0x96689f(_0x4edb78);});},'afterDestroy':function(_0x18e4f1,_0x89296,_0x8a7ef9){return _0x3b9ef6['VoiceExtension'][_0x5cf1('0x20')]({'where':{'ChanSpyId':_0x18e4f1['id']}})[_0x5cf1('0x17')](function(){_0x8a7ef9();})['catch'](function(_0x1b3c8b){_0x8a7ef9(_0x1b3c8b);});}}});};
\ No newline at end of file
+var _0x065b=['concat','internal','User','name','agent','then','catch','exports','models','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','system','chanspy','push','merge','MixMonitor','recordingFormat','auth','Authenticate','password','SIP/%s,%s','options','join','length'];(function(_0x422974,_0x11fa92){var _0x38ff85=function(_0x271d61){while(--_0x271d61){_0x422974['push'](_0x422974['shift']());}};_0x38ff85(++_0x11fa92);}(_0x065b,0x96));var _0xb065=function(_0x9ff1c0,_0x207afc){_0x9ff1c0=_0x9ff1c0-0x0;var _0x3e6c23=_0x065b[_0x9ff1c0];return _0x3e6c23;};'use strict';var _=require(_0xb065('0x0'));var util=require(_0xb065('0x1'));var BPromise=require(_0xb065('0x2'));var attributes=require(_0xb065('0x3'));var getUserApplications=function(_0x11d4a2,_0x597aee,_0x4e31ee){var _0x304d11=0x1;var _0x1cbe79=[];var _0x21b214={'context':_0x597aee[_0xb065('0x4')]||_0xb065('0x5'),'exten':util[_0xb065('0x6')]('%s%s',_0x11d4a2['prefix'],_0x4e31ee),'type':_0xb065('0x7'),'isApp':![],'ChanSpyId':_0x11d4a2['id'],'UserId':_0x597aee['id']};_0x1cbe79['push'](_['merge']({'app':'Set','appdata':util[_0xb065('0x6')]('CDR(type)=%s',_0xb065('0x8')),'priority':_0x304d11++},_0x21b214));if(_0x11d4a2['record']){_0x1cbe79[_0xb065('0x9')](_[_0xb065('0xa')]({'app':_0xb065('0xb'),'appdata':util['format']('${UNIQUEID}.%s,a',_0x11d4a2[_0xb065('0xc')]),'priority':_0x304d11++},_0x21b214));}if(_0x11d4a2[_0xb065('0xd')]){_0x1cbe79['push'](_[_0xb065('0xa')]({'app':_0xb065('0xe'),'appdata':_0x11d4a2[_0xb065('0xf')],'priority':_0x304d11++},_0x21b214));}_0x1cbe79['push'](_[_0xb065('0xa')]({'app':'ChanSpy','appdata':util[_0xb065('0x6')](_0xb065('0x10'),_0x597aee['name'],_0x11d4a2[_0xb065('0x11')]?_0x11d4a2['options'][_0xb065('0x12')](''):''),'priority':_0x304d11++},_0x21b214));if(_0x11d4a2['record']){_0x1cbe79[_0xb065('0x9')](_[_0xb065('0xa')]({'app':'StopMixMonitor','priority':_0x304d11++},_0x21b214));}return _0x1cbe79;};var getChanSpyApplications=function(_0xbea82c,_0x29757b){var _0x5eaf78=[];for(var _0x43de9a=0x0,_0x4919f4=0x1;_0x43de9a<_0x29757b[_0xb065('0x13')];_0x43de9a++,_0x4919f4=0x1){_0x5eaf78=_0x5eaf78[_0xb065('0x14')](getUserApplications(_0xbea82c,_0x29757b[_0x43de9a],_0x29757b[_0x43de9a][_0xb065('0x15')]));if(_0x29757b[_0x43de9a]['internal']!=_0x29757b[_0x43de9a]['name']){_0x5eaf78=_0x5eaf78[_0xb065('0x14')](getUserApplications(_0xbea82c,_0x29757b[_0x43de9a],_0x29757b[_0x43de9a]['name']));}}return _0x5eaf78;};var getChanSpyPromise=function(_0x1c0a58,_0x3a7611){return new BPromise(function(_0x349bfc,_0x575efc){return _0x1c0a58[_0xb065('0x16')]['findAll']({'attributes':['id',_0xb065('0x17'),_0xb065('0x15')],'where':{'role':_0xb065('0x18'),'chanspy':!![]},'raw':!![]})[_0xb065('0x19')](function(_0xc17f40){if(_0xc17f40){return _0x349bfc(getChanSpyApplications(_0x3a7611,_0xc17f40));}return _0x349bfc([]);})[_0xb065('0x1a')](function(_0x5c509e){_0x575efc(_0x5c509e);});});};module[_0xb065('0x1b')]=function(_0x2c3056,_0x2bb6d4){var _0x5d4af2=_0x2c3056[_0xb065('0x1c')];return _0x2c3056['define'](_0xb065('0x1d'),attributes,{'tableName':_0xb065('0x1e'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xfcac93,_0x35e3fc,_0x3ce85f){return getChanSpyPromise(_0x5d4af2,_0xfcac93)[_0xb065('0x19')](function(_0x28b446){if(_0x28b446&&_0x28b446['length']){return _0x5d4af2[_0xb065('0x1f')][_0xb065('0x20')](_0x28b446);}})[_0xb065('0x19')](function(){_0x3ce85f();})['catch'](function(_0x323e78){_0x3ce85f(_0x323e78);});},'afterUpdate':function(_0x474178,_0x21f61e,_0x500c36){return _0x5d4af2[_0xb065('0x1f')][_0xb065('0x21')]({'where':{'ChanSpyId':_0x474178['id']}})['then'](function(){return getChanSpyPromise(_0x5d4af2,_0x474178);})[_0xb065('0x19')](function(_0x1de942){if(_0x1de942&&_0x1de942[_0xb065('0x13')]){return _0x5d4af2[_0xb065('0x1f')][_0xb065('0x20')](_0x1de942);}})[_0xb065('0x19')](function(){_0x500c36();})[_0xb065('0x1a')](function(_0x2d50af){_0x500c36(_0x2d50af);});},'afterDestroy':function(_0x1d3cb3,_0x88f718,_0x104143){return _0x5d4af2[_0xb065('0x1f')][_0xb065('0x21')]({'where':{'ChanSpyId':_0x1d3cb3['id']}})['then'](function(){_0x104143();})[_0xb065('0x1a')](function(_0x542a0f){_0x104143(_0x542a0f);});}}});};
\ No newline at end of file