Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 3268a79..a407516 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x83ee=['VoiceExtension','destroy','util','bluebird','./voiceChanSpy.attributes','context','from-sip','%s%s','prefix','system','push','Set','format','CDR(type)=%s','chanspy','merge','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','ChanSpy','name','options','join','StopMixMonitor','length','concat','User','findAll','agent','catch','define','voice_chanspy','bulkCreate','then'];(function(_0x16aae9,_0x11031a){var _0x412d60=function(_0x78681){while(--_0x78681){_0x16aae9['push'](_0x16aae9['shift']());}};_0x412d60(++_0x11031a);}(_0x83ee,0xb6));var _0xe83e=function(_0xfcbcb8,_0x35bf6b){_0xfcbcb8=_0xfcbcb8-0x0;var _0x1b1f97=_0x83ee[_0xfcbcb8];return _0x1b1f97;};'use strict';var _=require('lodash');var util=require(_0xe83e('0x0'));var BPromise=require(_0xe83e('0x1'));var attributes=require(_0xe83e('0x2'));var getUserApplications=function(_0x1f83b0,_0xdb5b27,_0x2005e7){var _0x39d91a=0x1;var _0x451bb1=[];var _0x337d8e={'context':_0xdb5b27[_0xe83e('0x3')]||_0xe83e('0x4'),'exten':util['format'](_0xe83e('0x5'),_0x1f83b0[_0xe83e('0x6')],_0x2005e7),'type':_0xe83e('0x7'),'isApp':![],'ChanSpyId':_0x1f83b0['id'],'UserId':_0xdb5b27['id']};_0x451bb1[_0xe83e('0x8')](_['merge']({'app':_0xe83e('0x9'),'appdata':util[_0xe83e('0xa')](_0xe83e('0xb'),_0xe83e('0xc')),'priority':_0x39d91a++},_0x337d8e));if(_0x1f83b0['record']){_0x451bb1[_0xe83e('0x8')](_[_0xe83e('0xd')]({'app':'MixMonitor','appdata':util[_0xe83e('0xa')](_0xe83e('0xe'),_0x1f83b0[_0xe83e('0xf')]),'priority':_0x39d91a++},_0x337d8e));}if(_0x1f83b0[_0xe83e('0x10')]){_0x451bb1[_0xe83e('0x8')](_[_0xe83e('0xd')]({'app':_0xe83e('0x11'),'appdata':_0x1f83b0[_0xe83e('0x12')],'priority':_0x39d91a++},_0x337d8e));}_0x451bb1[_0xe83e('0x8')](_[_0xe83e('0xd')]({'app':_0xe83e('0x13'),'appdata':util[_0xe83e('0xa')]('SIP/%s,%s',_0xdb5b27[_0xe83e('0x14')],_0x1f83b0[_0xe83e('0x15')]?_0x1f83b0['options'][_0xe83e('0x16')](''):''),'priority':_0x39d91a++},_0x337d8e));if(_0x1f83b0['record']){_0x451bb1[_0xe83e('0x8')](_['merge']({'app':_0xe83e('0x17'),'priority':_0x39d91a++},_0x337d8e));}return _0x451bb1;};var getChanSpyApplications=function(_0x53814d,_0x374acf){var _0xa7899a=[];for(var _0x3561f6=0x0,_0x1b5cc0=0x1;_0x3561f6<_0x374acf[_0xe83e('0x18')];_0x3561f6++,_0x1b5cc0=0x1){_0xa7899a=_0xa7899a['concat'](getUserApplications(_0x53814d,_0x374acf[_0x3561f6],_0x374acf[_0x3561f6]['internal']));if(_0x374acf[_0x3561f6]['internal']!=_0x374acf[_0x3561f6]['name']){_0xa7899a=_0xa7899a[_0xe83e('0x19')](getUserApplications(_0x53814d,_0x374acf[_0x3561f6],_0x374acf[_0x3561f6]['name']));}}return _0xa7899a;};var getChanSpyPromise=function(_0x3a7cd3,_0x31c84f){return new BPromise(function(_0x389202,_0x3be8ae){return _0x3a7cd3[_0xe83e('0x1a')][_0xe83e('0x1b')]({'attributes':['id',_0xe83e('0x14'),'internal'],'where':{'role':_0xe83e('0x1c'),'chanspy':!![]},'raw':!![]})['then'](function(_0x2b917a){if(_0x2b917a){return _0x389202(getChanSpyApplications(_0x31c84f,_0x2b917a));}return _0x389202([]);})[_0xe83e('0x1d')](function(_0x5b055b){_0x3be8ae(_0x5b055b);});});};module['exports']=function(_0x74a30a,_0x10c68c){var _0x14e8af=_0x74a30a['models'];return _0x74a30a[_0xe83e('0x1e')]('VoiceChanSpy',attributes,{'tableName':_0xe83e('0x1f'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x3d3063,_0x11dfc8,_0x3baf63){return getChanSpyPromise(_0x14e8af,_0x3d3063)['then'](function(_0x340b1e){if(_0x340b1e&&_0x340b1e[_0xe83e('0x18')]){return _0x14e8af['VoiceExtension'][_0xe83e('0x20')](_0x340b1e);}})[_0xe83e('0x21')](function(){_0x3baf63();})[_0xe83e('0x1d')](function(_0x1ddefc){_0x3baf63(_0x1ddefc);});},'afterUpdate':function(_0x311a34,_0xb0d900,_0x5df910){return _0x14e8af[_0xe83e('0x22')][_0xe83e('0x23')]({'where':{'ChanSpyId':_0x311a34['id']}})[_0xe83e('0x21')](function(){return getChanSpyPromise(_0x14e8af,_0x311a34);})['then'](function(_0x2d4822){if(_0x2d4822&&_0x2d4822[_0xe83e('0x18')]){return _0x14e8af[_0xe83e('0x22')][_0xe83e('0x20')](_0x2d4822);}})[_0xe83e('0x21')](function(){_0x5df910();})[_0xe83e('0x1d')](function(_0x226dbf){_0x5df910(_0x226dbf);});},'afterDestroy':function(_0x10348d,_0x119001,_0x1d11ea){return _0x14e8af[_0xe83e('0x22')][_0xe83e('0x23')]({'where':{'ChanSpyId':_0x10348d['id']}})[_0xe83e('0x21')](function(){_0x1d11ea();})[_0xe83e('0x1d')](function(_0x5edf9f){_0x1d11ea(_0x5edf9f);});}}});};
\ No newline at end of file
+var _0x6026=['options','join','StopMixMonitor','length','concat','findAll','then','catch','exports','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','lodash','bluebird','./voiceChanSpy.attributes','context','from-sip','%s%s','prefix','system','merge','Set','format','CDR(type)=%s','chanspy','record','${UNIQUEID}.%s,a','recordingFormat','auth','password','push','ChanSpy','SIP/%s,%s','name'];(function(_0x551223,_0x4c84ed){var _0x12cf16=function(_0x2fe771){while(--_0x2fe771){_0x551223['push'](_0x551223['shift']());}};_0x12cf16(++_0x4c84ed);}(_0x6026,0x7e));var _0x6602=function(_0x4956d2,_0x12cf69){_0x4956d2=_0x4956d2-0x0;var _0x27d60c=_0x6026[_0x4956d2];return _0x27d60c;};'use strict';var _=require(_0x6602('0x0'));var util=require('util');var BPromise=require(_0x6602('0x1'));var attributes=require(_0x6602('0x2'));var getUserApplications=function(_0xc7a631,_0x1f72c6,_0x2d29e9){var _0x29afed=0x1;var _0x32a2ce=[];var _0x53ceb0={'context':_0x1f72c6[_0x6602('0x3')]||_0x6602('0x4'),'exten':util['format'](_0x6602('0x5'),_0xc7a631[_0x6602('0x6')],_0x2d29e9),'type':_0x6602('0x7'),'isApp':![],'ChanSpyId':_0xc7a631['id'],'UserId':_0x1f72c6['id']};_0x32a2ce['push'](_[_0x6602('0x8')]({'app':_0x6602('0x9'),'appdata':util[_0x6602('0xa')](_0x6602('0xb'),_0x6602('0xc')),'priority':_0x29afed++},_0x53ceb0));if(_0xc7a631[_0x6602('0xd')]){_0x32a2ce['push'](_['merge']({'app':'MixMonitor','appdata':util['format'](_0x6602('0xe'),_0xc7a631[_0x6602('0xf')]),'priority':_0x29afed++},_0x53ceb0));}if(_0xc7a631[_0x6602('0x10')]){_0x32a2ce['push'](_[_0x6602('0x8')]({'app':'Authenticate','appdata':_0xc7a631[_0x6602('0x11')],'priority':_0x29afed++},_0x53ceb0));}_0x32a2ce[_0x6602('0x12')](_['merge']({'app':_0x6602('0x13'),'appdata':util[_0x6602('0xa')](_0x6602('0x14'),_0x1f72c6[_0x6602('0x15')],_0xc7a631[_0x6602('0x16')]?_0xc7a631[_0x6602('0x16')][_0x6602('0x17')](''):''),'priority':_0x29afed++},_0x53ceb0));if(_0xc7a631[_0x6602('0xd')]){_0x32a2ce[_0x6602('0x12')](_['merge']({'app':_0x6602('0x18'),'priority':_0x29afed++},_0x53ceb0));}return _0x32a2ce;};var getChanSpyApplications=function(_0x2a2ce8,_0x349565){var _0x286442=[];for(var _0xc3e0dc=0x0,_0x30b217=0x1;_0xc3e0dc<_0x349565[_0x6602('0x19')];_0xc3e0dc++,_0x30b217=0x1){_0x286442=_0x286442['concat'](getUserApplications(_0x2a2ce8,_0x349565[_0xc3e0dc],_0x349565[_0xc3e0dc]['internal']));if(_0x349565[_0xc3e0dc]['internal']!=_0x349565[_0xc3e0dc][_0x6602('0x15')]){_0x286442=_0x286442[_0x6602('0x1a')](getUserApplications(_0x2a2ce8,_0x349565[_0xc3e0dc],_0x349565[_0xc3e0dc][_0x6602('0x15')]));}}return _0x286442;};var getChanSpyPromise=function(_0x359750,_0x39516f){return new BPromise(function(_0x5cf47e,_0x1348e7){return _0x359750['User'][_0x6602('0x1b')]({'attributes':['id','name','internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x6602('0x1c')](function(_0x77e714){if(_0x77e714){return _0x5cf47e(getChanSpyApplications(_0x39516f,_0x77e714));}return _0x5cf47e([]);})[_0x6602('0x1d')](function(_0x577777){_0x1348e7(_0x577777);});});};module[_0x6602('0x1e')]=function(_0x16b96f,_0x28cceb){var _0x29c187=_0x16b96f['models'];return _0x16b96f[_0x6602('0x1f')](_0x6602('0x20'),attributes,{'tableName':_0x6602('0x21'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x53634d,_0x3e27fb,_0x113c57){return getChanSpyPromise(_0x29c187,_0x53634d)[_0x6602('0x1c')](function(_0x4857ba){if(_0x4857ba&&_0x4857ba[_0x6602('0x19')]){return _0x29c187[_0x6602('0x22')]['bulkCreate'](_0x4857ba);}})['then'](function(){_0x113c57();})[_0x6602('0x1d')](function(_0x57624d){_0x113c57(_0x57624d);});},'afterUpdate':function(_0x55425e,_0x431b7b,_0x4e17ea){return _0x29c187['VoiceExtension']['destroy']({'where':{'ChanSpyId':_0x55425e['id']}})[_0x6602('0x1c')](function(){return getChanSpyPromise(_0x29c187,_0x55425e);})[_0x6602('0x1c')](function(_0xd30d6d){if(_0xd30d6d&&_0xd30d6d[_0x6602('0x19')]){return _0x29c187[_0x6602('0x22')][_0x6602('0x23')](_0xd30d6d);}})['then'](function(){_0x4e17ea();})[_0x6602('0x1d')](function(_0x1f1b95){_0x4e17ea(_0x1f1b95);});},'afterDestroy':function(_0x3f8003,_0x1cbeea,_0x494b18){return _0x29c187[_0x6602('0x22')][_0x6602('0x24')]({'where':{'ChanSpyId':_0x3f8003['id']}})[_0x6602('0x1c')](function(){_0x494b18();})[_0x6602('0x1d')](function(_0x3f3604){_0x494b18(_0x3f3604);});}}});};
\ No newline at end of file