Built motion from commit 08fb8613.|2.6.31
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 1908103..3b8ba6b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3ac8=['system','push','Set','CDR(type)=%s','chanspy','merge','${UNIQUEID}.%s,a','ChanSpy','name','options','record','StopMixMonitor','length','concat','internal','findAll','agent','then','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','catch','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','prefix'];(function(_0x3d42d8,_0x4cffaa){var _0x27fc41=function(_0x3a363b){while(--_0x3a363b){_0x3d42d8['push'](_0x3d42d8['shift']());}};_0x27fc41(++_0x4cffaa);}(_0x3ac8,0x18f));var _0x83ac=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3ac8[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x83ac('0x0'));var util=require(_0x83ac('0x1'));var BPromise=require(_0x83ac('0x2'));var attributes=require(_0x83ac('0x3'));var getUserApplications=function(_0x1db75e,_0x330d15,_0x387bac){var _0x4213c0=0x1;var _0x37d704=[];var _0x3e33bc={'context':_0x330d15[_0x83ac('0x4')]||_0x83ac('0x5'),'exten':util[_0x83ac('0x6')](_0x83ac('0x7'),_0x1db75e[_0x83ac('0x8')],_0x387bac),'type':_0x83ac('0x9'),'isApp':![],'ChanSpyId':_0x1db75e['id'],'UserId':_0x330d15['id']};_0x37d704[_0x83ac('0xa')](_['merge']({'app':_0x83ac('0xb'),'appdata':util[_0x83ac('0x6')](_0x83ac('0xc'),_0x83ac('0xd')),'priority':_0x4213c0++},_0x3e33bc));if(_0x1db75e['record']){_0x37d704[_0x83ac('0xa')](_[_0x83ac('0xe')]({'app':'MixMonitor','appdata':util[_0x83ac('0x6')](_0x83ac('0xf'),_0x1db75e['recordingFormat']),'priority':_0x4213c0++},_0x3e33bc));}if(_0x1db75e['auth']){_0x37d704[_0x83ac('0xa')](_[_0x83ac('0xe')]({'app':'Authenticate','appdata':_0x1db75e['password'],'priority':_0x4213c0++},_0x3e33bc));}_0x37d704[_0x83ac('0xa')](_[_0x83ac('0xe')]({'app':_0x83ac('0x10'),'appdata':util[_0x83ac('0x6')]('SIP/%s,%s',_0x330d15[_0x83ac('0x11')],_0x1db75e[_0x83ac('0x12')]?_0x1db75e[_0x83ac('0x12')]['join'](''):''),'priority':_0x4213c0++},_0x3e33bc));if(_0x1db75e[_0x83ac('0x13')]){_0x37d704['push'](_['merge']({'app':_0x83ac('0x14'),'priority':_0x4213c0++},_0x3e33bc));}return _0x37d704;};var getChanSpyApplications=function(_0x3bca57,_0x4a9fa6){var _0x5b1881=[];for(var _0xc8f298=0x0,_0x35dcd2=0x1;_0xc8f298<_0x4a9fa6[_0x83ac('0x15')];_0xc8f298++,_0x35dcd2=0x1){_0x5b1881=_0x5b1881[_0x83ac('0x16')](getUserApplications(_0x3bca57,_0x4a9fa6[_0xc8f298],_0x4a9fa6[_0xc8f298][_0x83ac('0x17')]));if(_0x4a9fa6[_0xc8f298]['internal']!=_0x4a9fa6[_0xc8f298]['name']){_0x5b1881=_0x5b1881['concat'](getUserApplications(_0x3bca57,_0x4a9fa6[_0xc8f298],_0x4a9fa6[_0xc8f298]['name']));}}return _0x5b1881;};var getChanSpyPromise=function(_0xfdd7ae,_0x3e33cf){return new BPromise(function(_0x4f40d4,_0x1047dd){return _0xfdd7ae['User'][_0x83ac('0x18')]({'attributes':['id',_0x83ac('0x11'),_0x83ac('0x17')],'where':{'role':_0x83ac('0x19'),'chanspy':!![]},'raw':!![]})[_0x83ac('0x1a')](function(_0x5d2284){if(_0x5d2284){return _0x4f40d4(getChanSpyApplications(_0x3e33cf,_0x5d2284));}return _0x4f40d4([]);})['catch'](function(_0x12d94c){_0x1047dd(_0x12d94c);});});};module['exports']=function(_0x50741e,_0xf8e28){var _0x32bd87=_0x50741e[_0x83ac('0x1b')];return _0x50741e[_0x83ac('0x1c')](_0x83ac('0x1d'),attributes,{'tableName':_0x83ac('0x1e'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x5c843b,_0x147c58,_0x1289c5){return getChanSpyPromise(_0x32bd87,_0x5c843b)[_0x83ac('0x1a')](function(_0x1622d7){if(_0x1622d7&&_0x1622d7['length']){return _0x32bd87[_0x83ac('0x1f')][_0x83ac('0x20')](_0x1622d7);}})[_0x83ac('0x1a')](function(){_0x1289c5();})[_0x83ac('0x21')](function(_0x12026e){_0x1289c5(_0x12026e);});},'afterUpdate':function(_0x4d3bde,_0x25eaa6,_0xc60011){return _0x32bd87[_0x83ac('0x1f')]['destroy']({'where':{'ChanSpyId':_0x4d3bde['id']}})[_0x83ac('0x1a')](function(){return getChanSpyPromise(_0x32bd87,_0x4d3bde);})[_0x83ac('0x1a')](function(_0x2398d1){if(_0x2398d1&&_0x2398d1[_0x83ac('0x15')]){return _0x32bd87[_0x83ac('0x1f')][_0x83ac('0x20')](_0x2398d1);}})[_0x83ac('0x1a')](function(){_0xc60011();})['catch'](function(_0x9b35c0){_0xc60011(_0x9b35c0);});},'afterDestroy':function(_0x25f558,_0x2320bd,_0x598055){return _0x32bd87[_0x83ac('0x1f')]['destroy']({'where':{'ChanSpyId':_0x25f558['id']}})[_0x83ac('0x1a')](function(){_0x598055();})[_0x83ac('0x21')](function(_0x20751b){_0x598055(_0x20751b);});}}});};
\ No newline at end of file
+var _0x5814=['context','format','prefix','system','push','merge','CDR(type)=%s','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','ChanSpy','name','options','join','StopMixMonitor','length','concat','internal','agent','then','catch','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','lodash','util','./voiceChanSpy.attributes'];(function(_0x4fde08,_0x463a36){var _0x12e725=function(_0x2670c5){while(--_0x2670c5){_0x4fde08['push'](_0x4fde08['shift']());}};_0x12e725(++_0x463a36);}(_0x5814,0x9d));var _0x4581=function(_0x52cdb3,_0x247869){_0x52cdb3=_0x52cdb3-0x0;var _0x23671e=_0x5814[_0x52cdb3];return _0x23671e;};'use strict';var _=require(_0x4581('0x0'));var util=require(_0x4581('0x1'));var BPromise=require('bluebird');var attributes=require(_0x4581('0x2'));var getUserApplications=function(_0x53d390,_0x4c0184,_0x11c3a9){var _0x192582=0x1;var _0x4dbbb3=[];var _0x2470fc={'context':_0x4c0184[_0x4581('0x3')]||'from-sip','exten':util[_0x4581('0x4')]('%s%s',_0x53d390[_0x4581('0x5')],_0x11c3a9),'type':_0x4581('0x6'),'isApp':![],'ChanSpyId':_0x53d390['id'],'UserId':_0x4c0184['id']};_0x4dbbb3[_0x4581('0x7')](_[_0x4581('0x8')]({'app':'Set','appdata':util[_0x4581('0x4')](_0x4581('0x9'),'chanspy'),'priority':_0x192582++},_0x2470fc));if(_0x53d390[_0x4581('0xa')]){_0x4dbbb3[_0x4581('0x7')](_[_0x4581('0x8')]({'app':_0x4581('0xb'),'appdata':util[_0x4581('0x4')](_0x4581('0xc'),_0x53d390[_0x4581('0xd')]),'priority':_0x192582++},_0x2470fc));}if(_0x53d390['auth']){_0x4dbbb3[_0x4581('0x7')](_[_0x4581('0x8')]({'app':_0x4581('0xe'),'appdata':_0x53d390[_0x4581('0xf')],'priority':_0x192582++},_0x2470fc));}_0x4dbbb3[_0x4581('0x7')](_['merge']({'app':_0x4581('0x10'),'appdata':util['format']('SIP/%s,%s',_0x4c0184[_0x4581('0x11')],_0x53d390[_0x4581('0x12')]?_0x53d390[_0x4581('0x12')][_0x4581('0x13')](''):''),'priority':_0x192582++},_0x2470fc));if(_0x53d390[_0x4581('0xa')]){_0x4dbbb3[_0x4581('0x7')](_[_0x4581('0x8')]({'app':_0x4581('0x14'),'priority':_0x192582++},_0x2470fc));}return _0x4dbbb3;};var getChanSpyApplications=function(_0x24a9ce,_0x1753cc){var _0x12e9ce=[];for(var _0x3e8b77=0x0,_0x5f1f82=0x1;_0x3e8b77<_0x1753cc[_0x4581('0x15')];_0x3e8b77++,_0x5f1f82=0x1){_0x12e9ce=_0x12e9ce[_0x4581('0x16')](getUserApplications(_0x24a9ce,_0x1753cc[_0x3e8b77],_0x1753cc[_0x3e8b77][_0x4581('0x17')]));if(_0x1753cc[_0x3e8b77][_0x4581('0x17')]!=_0x1753cc[_0x3e8b77][_0x4581('0x11')]){_0x12e9ce=_0x12e9ce[_0x4581('0x16')](getUserApplications(_0x24a9ce,_0x1753cc[_0x3e8b77],_0x1753cc[_0x3e8b77][_0x4581('0x11')]));}}return _0x12e9ce;};var getChanSpyPromise=function(_0x5d1e47,_0x12959f){return new BPromise(function(_0x570351,_0xce9407){return _0x5d1e47['User']['findAll']({'attributes':['id',_0x4581('0x11'),_0x4581('0x17')],'where':{'role':_0x4581('0x18'),'chanspy':!![]},'raw':!![]})[_0x4581('0x19')](function(_0x4ca663){if(_0x4ca663){return _0x570351(getChanSpyApplications(_0x12959f,_0x4ca663));}return _0x570351([]);})[_0x4581('0x1a')](function(_0xf9a70){_0xce9407(_0xf9a70);});});};module['exports']=function(_0x305faa,_0x519622){var _0x455c97=_0x305faa['models'];return _0x305faa['define'](_0x4581('0x1b'),attributes,{'tableName':_0x4581('0x1c'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x4ef972,_0x4b808e,_0x1c897a){return getChanSpyPromise(_0x455c97,_0x4ef972)[_0x4581('0x19')](function(_0x4a0dbb){if(_0x4a0dbb&&_0x4a0dbb['length']){return _0x455c97[_0x4581('0x1d')][_0x4581('0x1e')](_0x4a0dbb);}})[_0x4581('0x19')](function(){_0x1c897a();})['catch'](function(_0x3735c3){_0x1c897a(_0x3735c3);});},'afterUpdate':function(_0x14ff8f,_0x1a4729,_0x2a781b){return _0x455c97['VoiceExtension'][_0x4581('0x1f')]({'where':{'ChanSpyId':_0x14ff8f['id']}})[_0x4581('0x19')](function(){return getChanSpyPromise(_0x455c97,_0x14ff8f);})[_0x4581('0x19')](function(_0xcfcdfe){if(_0xcfcdfe&&_0xcfcdfe[_0x4581('0x15')]){return _0x455c97[_0x4581('0x1d')][_0x4581('0x1e')](_0xcfcdfe);}})[_0x4581('0x19')](function(){_0x2a781b();})[_0x4581('0x1a')](function(_0x4ac25f){_0x2a781b(_0x4ac25f);});},'afterDestroy':function(_0x11ab59,_0x5c065e,_0x4061bf){return _0x455c97[_0x4581('0x1d')][_0x4581('0x1f')]({'where':{'ChanSpyId':_0x11ab59['id']}})[_0x4581('0x19')](function(){_0x4061bf();})['catch'](function(_0x1c0320){_0x4061bf(_0x1c0320);});}}});};
\ No newline at end of file