Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 6aa2552..7fae2d1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1a2=['destroy','lodash','util','bluebird','format','%s%s','prefix','system','push','Set','CDR(type)=%s','chanspy','record','merge','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','ChanSpy','SIP/%s,%s','name','options','StopMixMonitor','length','internal','User','findAll','agent','then','catch','exports','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate'];(function(_0x1a6967,_0x95d92b){var _0x952e59=function(_0x6b63a9){while(--_0x6b63a9){_0x1a6967['push'](_0x1a6967['shift']());}};_0x952e59(++_0x95d92b);}(_0xf1a2,0x1a3));var _0x2f1a=function(_0x3ae5af,_0x45d0f2){_0x3ae5af=_0x3ae5af-0x0;var _0x543d0f=_0xf1a2[_0x3ae5af];return _0x543d0f;};'use strict';var _=require(_0x2f1a('0x0'));var util=require(_0x2f1a('0x1'));var BPromise=require(_0x2f1a('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x36ef95,_0x114cc1,_0x4a77d6){var _0x271e5a=0x1;var _0xdb1da0=[];var _0x26e1f4={'context':_0x114cc1['context']||'from-sip','exten':util[_0x2f1a('0x3')](_0x2f1a('0x4'),_0x36ef95[_0x2f1a('0x5')],_0x4a77d6),'type':_0x2f1a('0x6'),'isApp':![],'ChanSpyId':_0x36ef95['id'],'UserId':_0x114cc1['id']};_0xdb1da0[_0x2f1a('0x7')](_['merge']({'app':_0x2f1a('0x8'),'appdata':util['format'](_0x2f1a('0x9'),_0x2f1a('0xa')),'priority':_0x271e5a++},_0x26e1f4));if(_0x36ef95[_0x2f1a('0xb')]){_0xdb1da0[_0x2f1a('0x7')](_[_0x2f1a('0xc')]({'app':_0x2f1a('0xd'),'appdata':util[_0x2f1a('0x3')](_0x2f1a('0xe'),_0x36ef95[_0x2f1a('0xf')]),'priority':_0x271e5a++},_0x26e1f4));}if(_0x36ef95[_0x2f1a('0x10')]){_0xdb1da0[_0x2f1a('0x7')](_[_0x2f1a('0xc')]({'app':_0x2f1a('0x11'),'appdata':_0x36ef95[_0x2f1a('0x12')],'priority':_0x271e5a++},_0x26e1f4));}_0xdb1da0['push'](_[_0x2f1a('0xc')]({'app':_0x2f1a('0x13'),'appdata':util[_0x2f1a('0x3')](_0x2f1a('0x14'),_0x114cc1[_0x2f1a('0x15')],_0x36ef95[_0x2f1a('0x16')]?_0x36ef95[_0x2f1a('0x16')]['join'](''):''),'priority':_0x271e5a++},_0x26e1f4));if(_0x36ef95['record']){_0xdb1da0[_0x2f1a('0x7')](_[_0x2f1a('0xc')]({'app':_0x2f1a('0x17'),'priority':_0x271e5a++},_0x26e1f4));}return _0xdb1da0;};var getChanSpyApplications=function(_0x38549a,_0x5bf9e5){var _0x112d09=[];for(var _0x2072c6=0x0,_0x36c681=0x1;_0x2072c6<_0x5bf9e5[_0x2f1a('0x18')];_0x2072c6++,_0x36c681=0x1){_0x112d09=_0x112d09['concat'](getUserApplications(_0x38549a,_0x5bf9e5[_0x2072c6],_0x5bf9e5[_0x2072c6][_0x2f1a('0x19')]));if(_0x5bf9e5[_0x2072c6][_0x2f1a('0x19')]!=_0x5bf9e5[_0x2072c6]['name']){_0x112d09=_0x112d09['concat'](getUserApplications(_0x38549a,_0x5bf9e5[_0x2072c6],_0x5bf9e5[_0x2072c6][_0x2f1a('0x15')]));}}return _0x112d09;};var getChanSpyPromise=function(_0x40e301,_0x3af1d1){return new BPromise(function(_0x22a75c,_0x862f78){return _0x40e301[_0x2f1a('0x1a')][_0x2f1a('0x1b')]({'attributes':['id',_0x2f1a('0x15'),_0x2f1a('0x19')],'where':{'role':_0x2f1a('0x1c'),'chanspy':!![]},'raw':!![]})[_0x2f1a('0x1d')](function(_0x4438ac){if(_0x4438ac){return _0x22a75c(getChanSpyApplications(_0x3af1d1,_0x4438ac));}return _0x22a75c([]);})[_0x2f1a('0x1e')](function(_0x185b60){_0x862f78(_0x185b60);});});};module[_0x2f1a('0x1f')]=function(_0x59cef2,_0xec9428){var _0x4505cd=_0x59cef2['models'];return _0x59cef2[_0x2f1a('0x20')](_0x2f1a('0x21'),attributes,{'tableName':_0x2f1a('0x22'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xabe870,_0x1eca15,_0x323035){return getChanSpyPromise(_0x4505cd,_0xabe870)['then'](function(_0x1fec5e){if(_0x1fec5e&&_0x1fec5e[_0x2f1a('0x18')]){return _0x4505cd[_0x2f1a('0x23')][_0x2f1a('0x24')](_0x1fec5e);}})[_0x2f1a('0x1d')](function(){_0x323035();})['catch'](function(_0x570279){_0x323035(_0x570279);});},'afterUpdate':function(_0x52cd6f,_0x10bf26,_0xd3217a){return _0x4505cd['VoiceExtension'][_0x2f1a('0x25')]({'where':{'ChanSpyId':_0x52cd6f['id']}})[_0x2f1a('0x1d')](function(){return getChanSpyPromise(_0x4505cd,_0x52cd6f);})[_0x2f1a('0x1d')](function(_0x2fa4ca){if(_0x2fa4ca&&_0x2fa4ca[_0x2f1a('0x18')]){return _0x4505cd[_0x2f1a('0x23')]['bulkCreate'](_0x2fa4ca);}})['then'](function(){_0xd3217a();})[_0x2f1a('0x1e')](function(_0x52576c){_0xd3217a(_0x52576c);});},'afterDestroy':function(_0x393b3e,_0x1d23fc,_0x3aa53b){return _0x4505cd[_0x2f1a('0x23')][_0x2f1a('0x25')]({'where':{'ChanSpyId':_0x393b3e['id']}})['then'](function(){_0x3aa53b();})[_0x2f1a('0x1e')](function(_0x22692c){_0x3aa53b(_0x22692c);});}}});};
\ No newline at end of file
+var _0xca91=['voice_chanspy','VoiceExtension','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','prefix','system','push','merge','Set','CDR(type)=%s','chanspy','record','${UNIQUEID}.%s,a','auth','Authenticate','password','ChanSpy','SIP/%s,%s','name','join','StopMixMonitor','length','internal','User','agent','then','catch','models'];(function(_0x382c73,_0x199cab){var _0x1dd0bf=function(_0x358747){while(--_0x358747){_0x382c73['push'](_0x382c73['shift']());}};_0x1dd0bf(++_0x199cab);}(_0xca91,0x1ca));var _0x1ca9=function(_0x55d829,_0x43f06c){_0x55d829=_0x55d829-0x0;var _0x52163b=_0xca91[_0x55d829];return _0x52163b;};'use strict';var _=require(_0x1ca9('0x0'));var util=require(_0x1ca9('0x1'));var BPromise=require(_0x1ca9('0x2'));var attributes=require(_0x1ca9('0x3'));var getUserApplications=function(_0x39f79e,_0x188a17,_0x14fcca){var _0xfae222=0x1;var _0x5842f7=[];var _0x111612={'context':_0x188a17[_0x1ca9('0x4')]||_0x1ca9('0x5'),'exten':util[_0x1ca9('0x6')](_0x1ca9('0x7'),_0x39f79e[_0x1ca9('0x8')],_0x14fcca),'type':_0x1ca9('0x9'),'isApp':![],'ChanSpyId':_0x39f79e['id'],'UserId':_0x188a17['id']};_0x5842f7[_0x1ca9('0xa')](_[_0x1ca9('0xb')]({'app':_0x1ca9('0xc'),'appdata':util[_0x1ca9('0x6')](_0x1ca9('0xd'),_0x1ca9('0xe')),'priority':_0xfae222++},_0x111612));if(_0x39f79e[_0x1ca9('0xf')]){_0x5842f7[_0x1ca9('0xa')](_[_0x1ca9('0xb')]({'app':'MixMonitor','appdata':util[_0x1ca9('0x6')](_0x1ca9('0x10'),_0x39f79e['recordingFormat']),'priority':_0xfae222++},_0x111612));}if(_0x39f79e[_0x1ca9('0x11')]){_0x5842f7[_0x1ca9('0xa')](_['merge']({'app':_0x1ca9('0x12'),'appdata':_0x39f79e[_0x1ca9('0x13')],'priority':_0xfae222++},_0x111612));}_0x5842f7[_0x1ca9('0xa')](_[_0x1ca9('0xb')]({'app':_0x1ca9('0x14'),'appdata':util['format'](_0x1ca9('0x15'),_0x188a17[_0x1ca9('0x16')],_0x39f79e['options']?_0x39f79e['options'][_0x1ca9('0x17')](''):''),'priority':_0xfae222++},_0x111612));if(_0x39f79e[_0x1ca9('0xf')]){_0x5842f7[_0x1ca9('0xa')](_[_0x1ca9('0xb')]({'app':_0x1ca9('0x18'),'priority':_0xfae222++},_0x111612));}return _0x5842f7;};var getChanSpyApplications=function(_0x1c4d7f,_0x1ab498){var _0x287a2e=[];for(var _0x56cc61=0x0,_0x107a8e=0x1;_0x56cc61<_0x1ab498[_0x1ca9('0x19')];_0x56cc61++,_0x107a8e=0x1){_0x287a2e=_0x287a2e['concat'](getUserApplications(_0x1c4d7f,_0x1ab498[_0x56cc61],_0x1ab498[_0x56cc61]['internal']));if(_0x1ab498[_0x56cc61][_0x1ca9('0x1a')]!=_0x1ab498[_0x56cc61][_0x1ca9('0x16')]){_0x287a2e=_0x287a2e['concat'](getUserApplications(_0x1c4d7f,_0x1ab498[_0x56cc61],_0x1ab498[_0x56cc61][_0x1ca9('0x16')]));}}return _0x287a2e;};var getChanSpyPromise=function(_0x55ac57,_0x402283){return new BPromise(function(_0x29820c,_0x2b92d7){return _0x55ac57[_0x1ca9('0x1b')]['findAll']({'attributes':['id',_0x1ca9('0x16'),_0x1ca9('0x1a')],'where':{'role':_0x1ca9('0x1c'),'chanspy':!![]},'raw':!![]})[_0x1ca9('0x1d')](function(_0x5a7ee5){if(_0x5a7ee5){return _0x29820c(getChanSpyApplications(_0x402283,_0x5a7ee5));}return _0x29820c([]);})[_0x1ca9('0x1e')](function(_0xf12db){_0x2b92d7(_0xf12db);});});};module['exports']=function(_0x263c61,_0x11202d){var _0x4cc184=_0x263c61[_0x1ca9('0x1f')];return _0x263c61['define']('VoiceChanSpy',attributes,{'tableName':_0x1ca9('0x20'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1b5f60,_0x5a30bb,_0x52d143){return getChanSpyPromise(_0x4cc184,_0x1b5f60)['then'](function(_0x3aea88){if(_0x3aea88&&_0x3aea88[_0x1ca9('0x19')]){return _0x4cc184[_0x1ca9('0x21')]['bulkCreate'](_0x3aea88);}})[_0x1ca9('0x1d')](function(){_0x52d143();})[_0x1ca9('0x1e')](function(_0x41445a){_0x52d143(_0x41445a);});},'afterUpdate':function(_0xe29ae3,_0x1f56a3,_0xf82b3e){return _0x4cc184[_0x1ca9('0x21')]['destroy']({'where':{'ChanSpyId':_0xe29ae3['id']}})[_0x1ca9('0x1d')](function(){return getChanSpyPromise(_0x4cc184,_0xe29ae3);})[_0x1ca9('0x1d')](function(_0x2b9c1f){if(_0x2b9c1f&&_0x2b9c1f[_0x1ca9('0x19')]){return _0x4cc184[_0x1ca9('0x21')]['bulkCreate'](_0x2b9c1f);}})[_0x1ca9('0x1d')](function(){_0xf82b3e();})[_0x1ca9('0x1e')](function(_0x35195f){_0xf82b3e(_0x35195f);});},'afterDestroy':function(_0x420108,_0x3fe8e7,_0x568d20){return _0x4cc184[_0x1ca9('0x21')][_0x1ca9('0x22')]({'where':{'ChanSpyId':_0x420108['id']}})[_0x1ca9('0x1d')](function(){_0x568d20();})[_0x1ca9('0x1e')](function(_0x52bd89){_0x568d20(_0x52bd89);});}}});};
\ No newline at end of file