Built motion from commit d301b742.|2.6.29
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index aee13e6..84fc273 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x11a2=['password','ChanSpy','options','join','StopMixMonitor','concat','internal','name','User','agent','catch','exports','models','define','voice_chanspy','then','length','bulkCreate','VoiceExtension','destroy','context','from-sip','prefix','system','push','format','CDR(type)=%s','merge','MixMonitor','${UNIQUEID}.%s,a','auth','Authenticate'];(function(_0x4aa838,_0x4aa14f){var _0x3abff0=function(_0x402d55){while(--_0x402d55){_0x4aa838['push'](_0x4aa838['shift']());}};_0x3abff0(++_0x4aa14f);}(_0x11a2,0x1f4));var _0x211a=function(_0x379a15,_0x2242d6){_0x379a15=_0x379a15-0x0;var _0x4e20fa=_0x11a2[_0x379a15];return _0x4e20fa;};'use strict';var _=require('lodash');var util=require('util');var BPromise=require('bluebird');var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x78f916,_0x4961be,_0x386e91){var _0x430f9f=0x1;var _0x1a82ad=[];var _0xda79bc={'context':_0x4961be[_0x211a('0x0')]||_0x211a('0x1'),'exten':util['format']('%s%s',_0x78f916[_0x211a('0x2')],_0x386e91),'type':_0x211a('0x3'),'isApp':![],'ChanSpyId':_0x78f916['id'],'UserId':_0x4961be['id']};_0x1a82ad[_0x211a('0x4')](_['merge']({'app':'Set','appdata':util[_0x211a('0x5')](_0x211a('0x6'),'chanspy'),'priority':_0x430f9f++},_0xda79bc));if(_0x78f916['record']){_0x1a82ad['push'](_[_0x211a('0x7')]({'app':_0x211a('0x8'),'appdata':util[_0x211a('0x5')](_0x211a('0x9'),_0x78f916['recordingFormat']),'priority':_0x430f9f++},_0xda79bc));}if(_0x78f916[_0x211a('0xa')]){_0x1a82ad[_0x211a('0x4')](_[_0x211a('0x7')]({'app':_0x211a('0xb'),'appdata':_0x78f916[_0x211a('0xc')],'priority':_0x430f9f++},_0xda79bc));}_0x1a82ad[_0x211a('0x4')](_['merge']({'app':_0x211a('0xd'),'appdata':util[_0x211a('0x5')]('SIP/%s,%s',_0x4961be['name'],_0x78f916[_0x211a('0xe')]?_0x78f916[_0x211a('0xe')][_0x211a('0xf')](''):''),'priority':_0x430f9f++},_0xda79bc));if(_0x78f916['record']){_0x1a82ad[_0x211a('0x4')](_[_0x211a('0x7')]({'app':_0x211a('0x10'),'priority':_0x430f9f++},_0xda79bc));}return _0x1a82ad;};var getChanSpyApplications=function(_0xdd2605,_0x18ffd3){var _0x7e475b=[];for(var _0x16852f=0x0,_0x1dff51=0x1;_0x16852f<_0x18ffd3['length'];_0x16852f++,_0x1dff51=0x1){_0x7e475b=_0x7e475b[_0x211a('0x11')](getUserApplications(_0xdd2605,_0x18ffd3[_0x16852f],_0x18ffd3[_0x16852f][_0x211a('0x12')]));if(_0x18ffd3[_0x16852f][_0x211a('0x12')]!=_0x18ffd3[_0x16852f][_0x211a('0x13')]){_0x7e475b=_0x7e475b[_0x211a('0x11')](getUserApplications(_0xdd2605,_0x18ffd3[_0x16852f],_0x18ffd3[_0x16852f][_0x211a('0x13')]));}}return _0x7e475b;};var getChanSpyPromise=function(_0x2f80ca,_0x1be294){return new BPromise(function(_0x167d40,_0x281377){return _0x2f80ca[_0x211a('0x14')]['findAll']({'attributes':['id',_0x211a('0x13'),'internal'],'where':{'role':_0x211a('0x15'),'chanspy':!![]},'raw':!![]})['then'](function(_0xa13824){if(_0xa13824){return _0x167d40(getChanSpyApplications(_0x1be294,_0xa13824));}return _0x167d40([]);})[_0x211a('0x16')](function(_0x5a383e){_0x281377(_0x5a383e);});});};module[_0x211a('0x17')]=function(_0x3c95cc,_0x3332d8){var _0x5c72a0=_0x3c95cc[_0x211a('0x18')];return _0x3c95cc[_0x211a('0x19')]('VoiceChanSpy',attributes,{'tableName':_0x211a('0x1a'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xf9f721,_0x338b64,_0xa347e2){return getChanSpyPromise(_0x5c72a0,_0xf9f721)[_0x211a('0x1b')](function(_0x481400){if(_0x481400&&_0x481400[_0x211a('0x1c')]){return _0x5c72a0['VoiceExtension'][_0x211a('0x1d')](_0x481400);}})[_0x211a('0x1b')](function(){_0xa347e2();})[_0x211a('0x16')](function(_0xf7ee58){_0xa347e2(_0xf7ee58);});},'afterUpdate':function(_0x2b5735,_0x3c1a03,_0x38a259){return _0x5c72a0[_0x211a('0x1e')][_0x211a('0x1f')]({'where':{'ChanSpyId':_0x2b5735['id']}})['then'](function(){return getChanSpyPromise(_0x5c72a0,_0x2b5735);})[_0x211a('0x1b')](function(_0x55c408){if(_0x55c408&&_0x55c408[_0x211a('0x1c')]){return _0x5c72a0[_0x211a('0x1e')]['bulkCreate'](_0x55c408);}})[_0x211a('0x1b')](function(){_0x38a259();})['catch'](function(_0x2f4f69){_0x38a259(_0x2f4f69);});},'afterDestroy':function(_0x51491b,_0x831ef1,_0x250492){return _0x5c72a0[_0x211a('0x1e')][_0x211a('0x1f')]({'where':{'ChanSpyId':_0x51491b['id']}})[_0x211a('0x1b')](function(){_0x250492();})[_0x211a('0x16')](function(_0x3af73c){_0x250492(_0x3af73c);});}}});};
\ No newline at end of file
+var _0xbf21=['merge','Set','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','ChanSpy','format','name','options','StopMixMonitor','length','concat','internal','User','agent','then','catch','exports','models','voice_chanspy','VoiceExtension','destroy','bulkCreate','lodash','context','from-sip','%s%s','push'];(function(_0x45931b,_0x118392){var _0x36ca13=function(_0x1d9c37){while(--_0x1d9c37){_0x45931b['push'](_0x45931b['shift']());}};_0x36ca13(++_0x118392);}(_0xbf21,0xc1));var _0x1bf2=function(_0x1324a3,_0x2fdebd){_0x1324a3=_0x1324a3-0x0;var _0x57dfea=_0xbf21[_0x1324a3];return _0x57dfea;};'use strict';var _=require(_0x1bf2('0x0'));var util=require('util');var BPromise=require('bluebird');var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0xd52226,_0x240745,_0x2d612a){var _0x14c485=0x1;var _0x2d48ad=[];var _0x22fc3a={'context':_0x240745[_0x1bf2('0x1')]||_0x1bf2('0x2'),'exten':util['format'](_0x1bf2('0x3'),_0xd52226['prefix'],_0x2d612a),'type':'system','isApp':![],'ChanSpyId':_0xd52226['id'],'UserId':_0x240745['id']};_0x2d48ad[_0x1bf2('0x4')](_[_0x1bf2('0x5')]({'app':_0x1bf2('0x6'),'appdata':util['format'](_0x1bf2('0x7'),_0x1bf2('0x8')),'priority':_0x14c485++},_0x22fc3a));if(_0xd52226[_0x1bf2('0x9')]){_0x2d48ad[_0x1bf2('0x4')](_['merge']({'app':_0x1bf2('0xa'),'appdata':util['format'](_0x1bf2('0xb'),_0xd52226[_0x1bf2('0xc')]),'priority':_0x14c485++},_0x22fc3a));}if(_0xd52226[_0x1bf2('0xd')]){_0x2d48ad[_0x1bf2('0x4')](_[_0x1bf2('0x5')]({'app':_0x1bf2('0xe'),'appdata':_0xd52226['password'],'priority':_0x14c485++},_0x22fc3a));}_0x2d48ad[_0x1bf2('0x4')](_['merge']({'app':_0x1bf2('0xf'),'appdata':util[_0x1bf2('0x10')]('SIP/%s,%s',_0x240745[_0x1bf2('0x11')],_0xd52226[_0x1bf2('0x12')]?_0xd52226[_0x1bf2('0x12')]['join'](''):''),'priority':_0x14c485++},_0x22fc3a));if(_0xd52226['record']){_0x2d48ad['push'](_[_0x1bf2('0x5')]({'app':_0x1bf2('0x13'),'priority':_0x14c485++},_0x22fc3a));}return _0x2d48ad;};var getChanSpyApplications=function(_0x509f1f,_0x49a4a5){var _0xb2c089=[];for(var _0x34829d=0x0,_0x4917c0=0x1;_0x34829d<_0x49a4a5[_0x1bf2('0x14')];_0x34829d++,_0x4917c0=0x1){_0xb2c089=_0xb2c089[_0x1bf2('0x15')](getUserApplications(_0x509f1f,_0x49a4a5[_0x34829d],_0x49a4a5[_0x34829d][_0x1bf2('0x16')]));if(_0x49a4a5[_0x34829d][_0x1bf2('0x16')]!=_0x49a4a5[_0x34829d][_0x1bf2('0x11')]){_0xb2c089=_0xb2c089[_0x1bf2('0x15')](getUserApplications(_0x509f1f,_0x49a4a5[_0x34829d],_0x49a4a5[_0x34829d]['name']));}}return _0xb2c089;};var getChanSpyPromise=function(_0x2159f0,_0x1d12f3){return new BPromise(function(_0x39288d,_0x58fc8f){return _0x2159f0[_0x1bf2('0x17')]['findAll']({'attributes':['id','name',_0x1bf2('0x16')],'where':{'role':_0x1bf2('0x18'),'chanspy':!![]},'raw':!![]})[_0x1bf2('0x19')](function(_0xc13895){if(_0xc13895){return _0x39288d(getChanSpyApplications(_0x1d12f3,_0xc13895));}return _0x39288d([]);})[_0x1bf2('0x1a')](function(_0x576e0d){_0x58fc8f(_0x576e0d);});});};module[_0x1bf2('0x1b')]=function(_0x26a089,_0x2d453){var _0xd95690=_0x26a089[_0x1bf2('0x1c')];return _0x26a089['define']('VoiceChanSpy',attributes,{'tableName':_0x1bf2('0x1d'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1a20eb,_0x46e827,_0x4d70bc){return getChanSpyPromise(_0xd95690,_0x1a20eb)['then'](function(_0x530a44){if(_0x530a44&&_0x530a44[_0x1bf2('0x14')]){return _0xd95690[_0x1bf2('0x1e')]['bulkCreate'](_0x530a44);}})[_0x1bf2('0x19')](function(){_0x4d70bc();})[_0x1bf2('0x1a')](function(_0x15436b){_0x4d70bc(_0x15436b);});},'afterUpdate':function(_0x301df6,_0x282804,_0x1a52dc){return _0xd95690[_0x1bf2('0x1e')][_0x1bf2('0x1f')]({'where':{'ChanSpyId':_0x301df6['id']}})[_0x1bf2('0x19')](function(){return getChanSpyPromise(_0xd95690,_0x301df6);})['then'](function(_0x3cf3bf){if(_0x3cf3bf&&_0x3cf3bf[_0x1bf2('0x14')]){return _0xd95690[_0x1bf2('0x1e')][_0x1bf2('0x20')](_0x3cf3bf);}})[_0x1bf2('0x19')](function(){_0x1a52dc();})[_0x1bf2('0x1a')](function(_0xb71541){_0x1a52dc(_0xb71541);});},'afterDestroy':function(_0x2e4580,_0x332eda,_0x26ab35){return _0xd95690[_0x1bf2('0x1e')][_0x1bf2('0x1f')]({'where':{'ChanSpyId':_0x2e4580['id']}})[_0x1bf2('0x19')](function(){_0x26ab35();})['catch'](function(_0x29aec0){_0x26ab35(_0x29aec0);});}}});};
\ No newline at end of file