Built motion from commit b7e79837.|2.6.29
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index c8008af..f19f964 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x98a4=['then','models','VoiceChanSpy','voice_chanspy','length','bulkCreate','VoiceExtension','catch','destroy','util','./voiceChanSpy.attributes','context','format','%s%s','merge','Set','CDR(type)=%s','record','push','MixMonitor','${UNIQUEID}.%s,a','auth','Authenticate','password','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','internal','concat','findAll','agent'];(function(_0x2fa2d6,_0x5d7dc8){var _0x3eb8ab=function(_0x23081f){while(--_0x23081f){_0x2fa2d6['push'](_0x2fa2d6['shift']());}};_0x3eb8ab(++_0x5d7dc8);}(_0x98a4,0x1c3));var _0x498a=function(_0x43a83b,_0x848a9b){_0x43a83b=_0x43a83b-0x0;var _0x5cb06a=_0x98a4[_0x43a83b];return _0x5cb06a;};'use strict';var _=require('lodash');var util=require(_0x498a('0x0'));var BPromise=require('bluebird');var attributes=require(_0x498a('0x1'));var getUserApplications=function(_0x5375e9,_0x562cff,_0x61e64){var _0x59b8b9=0x1;var _0x33b23d=[];var _0xe75802={'context':_0x562cff[_0x498a('0x2')]||'from-sip','exten':util[_0x498a('0x3')](_0x498a('0x4'),_0x5375e9['prefix'],_0x61e64),'type':'system','isApp':![],'ChanSpyId':_0x5375e9['id'],'UserId':_0x562cff['id']};_0x33b23d['push'](_[_0x498a('0x5')]({'app':_0x498a('0x6'),'appdata':util['format'](_0x498a('0x7'),'chanspy'),'priority':_0x59b8b9++},_0xe75802));if(_0x5375e9[_0x498a('0x8')]){_0x33b23d[_0x498a('0x9')](_[_0x498a('0x5')]({'app':_0x498a('0xa'),'appdata':util[_0x498a('0x3')](_0x498a('0xb'),_0x5375e9['recordingFormat']),'priority':_0x59b8b9++},_0xe75802));}if(_0x5375e9[_0x498a('0xc')]){_0x33b23d[_0x498a('0x9')](_['merge']({'app':_0x498a('0xd'),'appdata':_0x5375e9[_0x498a('0xe')],'priority':_0x59b8b9++},_0xe75802));}_0x33b23d[_0x498a('0x9')](_['merge']({'app':_0x498a('0xf'),'appdata':util['format'](_0x498a('0x10'),_0x562cff[_0x498a('0x11')],_0x5375e9[_0x498a('0x12')]?_0x5375e9[_0x498a('0x12')][_0x498a('0x13')](''):''),'priority':_0x59b8b9++},_0xe75802));if(_0x5375e9[_0x498a('0x8')]){_0x33b23d[_0x498a('0x9')](_['merge']({'app':_0x498a('0x14'),'priority':_0x59b8b9++},_0xe75802));}return _0x33b23d;};var getChanSpyApplications=function(_0x463a3a,_0x372315){var _0x28d154=[];for(var _0x9047f3=0x0,_0x5dcab2=0x1;_0x9047f3<_0x372315['length'];_0x9047f3++,_0x5dcab2=0x1){_0x28d154=_0x28d154['concat'](getUserApplications(_0x463a3a,_0x372315[_0x9047f3],_0x372315[_0x9047f3][_0x498a('0x15')]));if(_0x372315[_0x9047f3][_0x498a('0x15')]!=_0x372315[_0x9047f3][_0x498a('0x11')]){_0x28d154=_0x28d154[_0x498a('0x16')](getUserApplications(_0x463a3a,_0x372315[_0x9047f3],_0x372315[_0x9047f3]['name']));}}return _0x28d154;};var getChanSpyPromise=function(_0x5bf1d9,_0x17f7c4){return new BPromise(function(_0x473f05,_0x45e882){return _0x5bf1d9['User'][_0x498a('0x17')]({'attributes':['id','name',_0x498a('0x15')],'where':{'role':_0x498a('0x18'),'chanspy':!![]},'raw':!![]})[_0x498a('0x19')](function(_0x21213e){if(_0x21213e){return _0x473f05(getChanSpyApplications(_0x17f7c4,_0x21213e));}return _0x473f05([]);})['catch'](function(_0x5870d7){_0x45e882(_0x5870d7);});});};module['exports']=function(_0x2ac1bf,_0x587c64){var _0x106eca=_0x2ac1bf[_0x498a('0x1a')];return _0x2ac1bf['define'](_0x498a('0x1b'),attributes,{'tableName':_0x498a('0x1c'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x38bb28,_0x14e0ab,_0x4ecf56){return getChanSpyPromise(_0x106eca,_0x38bb28)[_0x498a('0x19')](function(_0x240ceb){if(_0x240ceb&&_0x240ceb[_0x498a('0x1d')]){return _0x106eca['VoiceExtension'][_0x498a('0x1e')](_0x240ceb);}})['then'](function(){_0x4ecf56();})['catch'](function(_0x582dc1){_0x4ecf56(_0x582dc1);});},'afterUpdate':function(_0x4101b6,_0x167c43,_0x2de827){return _0x106eca['VoiceExtension']['destroy']({'where':{'ChanSpyId':_0x4101b6['id']}})[_0x498a('0x19')](function(){return getChanSpyPromise(_0x106eca,_0x4101b6);})[_0x498a('0x19')](function(_0x477ad2){if(_0x477ad2&&_0x477ad2[_0x498a('0x1d')]){return _0x106eca[_0x498a('0x1f')][_0x498a('0x1e')](_0x477ad2);}})[_0x498a('0x19')](function(){_0x2de827();})[_0x498a('0x20')](function(_0x215f96){_0x2de827(_0x215f96);});},'afterDestroy':function(_0x1a3c85,_0x33e045,_0xddc247){return _0x106eca[_0x498a('0x1f')][_0x498a('0x21')]({'where':{'ChanSpyId':_0x1a3c85['id']}})[_0x498a('0x19')](function(){_0xddc247();})[_0x498a('0x20')](function(_0x49a8cb){_0xddc247(_0x49a8cb);});}}});};
\ No newline at end of file
+var _0x7399=['util','bluebird','./voiceChanSpy.attributes','from-sip','%s%s','prefix','push','merge','Set','format','CDR(type)=%s','chanspy','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','ChanSpy','SIP/%s,%s','name','options','join','record','length','internal','concat','User','findAll','agent','then','catch','models','define','VoiceChanSpy','VoiceExtension','bulkCreate','lodash'];(function(_0x383f90,_0x42edf5){var _0x101752=function(_0x2669c9){while(--_0x2669c9){_0x383f90['push'](_0x383f90['shift']());}};_0x101752(++_0x42edf5);}(_0x7399,0x18b));var _0x9739=function(_0x1dc5a7,_0x448a9f){_0x1dc5a7=_0x1dc5a7-0x0;var _0x4b3f3e=_0x7399[_0x1dc5a7];return _0x4b3f3e;};'use strict';var _=require(_0x9739('0x0'));var util=require(_0x9739('0x1'));var BPromise=require(_0x9739('0x2'));var attributes=require(_0x9739('0x3'));var getUserApplications=function(_0x41504d,_0x162e5a,_0x5cc461){var _0x2e9728=0x1;var _0x11b44d=[];var _0x4b598d={'context':_0x162e5a['context']||_0x9739('0x4'),'exten':util['format'](_0x9739('0x5'),_0x41504d[_0x9739('0x6')],_0x5cc461),'type':'system','isApp':![],'ChanSpyId':_0x41504d['id'],'UserId':_0x162e5a['id']};_0x11b44d[_0x9739('0x7')](_[_0x9739('0x8')]({'app':_0x9739('0x9'),'appdata':util[_0x9739('0xa')](_0x9739('0xb'),_0x9739('0xc')),'priority':_0x2e9728++},_0x4b598d));if(_0x41504d['record']){_0x11b44d[_0x9739('0x7')](_['merge']({'app':_0x9739('0xd'),'appdata':util[_0x9739('0xa')](_0x9739('0xe'),_0x41504d[_0x9739('0xf')]),'priority':_0x2e9728++},_0x4b598d));}if(_0x41504d['auth']){_0x11b44d[_0x9739('0x7')](_[_0x9739('0x8')]({'app':_0x9739('0x10'),'appdata':_0x41504d['password'],'priority':_0x2e9728++},_0x4b598d));}_0x11b44d[_0x9739('0x7')](_[_0x9739('0x8')]({'app':_0x9739('0x11'),'appdata':util[_0x9739('0xa')](_0x9739('0x12'),_0x162e5a[_0x9739('0x13')],_0x41504d[_0x9739('0x14')]?_0x41504d[_0x9739('0x14')][_0x9739('0x15')](''):''),'priority':_0x2e9728++},_0x4b598d));if(_0x41504d[_0x9739('0x16')]){_0x11b44d[_0x9739('0x7')](_[_0x9739('0x8')]({'app':'StopMixMonitor','priority':_0x2e9728++},_0x4b598d));}return _0x11b44d;};var getChanSpyApplications=function(_0x3da1ae,_0x38ee44){var _0x52d1bc=[];for(var _0x4b8605=0x0,_0x3e4132=0x1;_0x4b8605<_0x38ee44[_0x9739('0x17')];_0x4b8605++,_0x3e4132=0x1){_0x52d1bc=_0x52d1bc['concat'](getUserApplications(_0x3da1ae,_0x38ee44[_0x4b8605],_0x38ee44[_0x4b8605][_0x9739('0x18')]));if(_0x38ee44[_0x4b8605][_0x9739('0x18')]!=_0x38ee44[_0x4b8605]['name']){_0x52d1bc=_0x52d1bc[_0x9739('0x19')](getUserApplications(_0x3da1ae,_0x38ee44[_0x4b8605],_0x38ee44[_0x4b8605][_0x9739('0x13')]));}}return _0x52d1bc;};var getChanSpyPromise=function(_0x247730,_0x39f33c){return new BPromise(function(_0x5efc4f,_0x5beb02){return _0x247730[_0x9739('0x1a')][_0x9739('0x1b')]({'attributes':['id','name',_0x9739('0x18')],'where':{'role':_0x9739('0x1c'),'chanspy':!![]},'raw':!![]})[_0x9739('0x1d')](function(_0xeb72fa){if(_0xeb72fa){return _0x5efc4f(getChanSpyApplications(_0x39f33c,_0xeb72fa));}return _0x5efc4f([]);})[_0x9739('0x1e')](function(_0x1c1f90){_0x5beb02(_0x1c1f90);});});};module['exports']=function(_0x1fba06,_0x43633e){var _0x4d033e=_0x1fba06[_0x9739('0x1f')];return _0x1fba06[_0x9739('0x20')](_0x9739('0x21'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x4054a4,_0x4c7e29,_0x4d9af9){return getChanSpyPromise(_0x4d033e,_0x4054a4)[_0x9739('0x1d')](function(_0x1b08db){if(_0x1b08db&&_0x1b08db[_0x9739('0x17')]){return _0x4d033e[_0x9739('0x22')][_0x9739('0x23')](_0x1b08db);}})['then'](function(){_0x4d9af9();})['catch'](function(_0x29c858){_0x4d9af9(_0x29c858);});},'afterUpdate':function(_0x3c823c,_0x13e6eb,_0x1cc8a9){return _0x4d033e[_0x9739('0x22')]['destroy']({'where':{'ChanSpyId':_0x3c823c['id']}})[_0x9739('0x1d')](function(){return getChanSpyPromise(_0x4d033e,_0x3c823c);})[_0x9739('0x1d')](function(_0x282ff6){if(_0x282ff6&&_0x282ff6[_0x9739('0x17')]){return _0x4d033e[_0x9739('0x22')][_0x9739('0x23')](_0x282ff6);}})[_0x9739('0x1d')](function(){_0x1cc8a9();})['catch'](function(_0x338a0f){_0x1cc8a9(_0x338a0f);});},'afterDestroy':function(_0xef00df,_0x37bf43,_0xdb0aaf){return _0x4d033e[_0x9739('0x22')]['destroy']({'where':{'ChanSpyId':_0xef00df['id']}})[_0x9739('0x1d')](function(){_0xdb0aaf();})[_0x9739('0x1e')](function(_0xf4bb4e){_0xdb0aaf(_0xf4bb4e);});}}});};
\ No newline at end of file