Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 91c6f25..38ba1a0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7aad=['concat','internal','User','then','catch','exports','models','define','VoiceChanSpy','VoiceExtension','bulkCreate','destroy','lodash','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','push','Set','chanspy','record','merge','MixMonitor','auth','Authenticate','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','length'];(function(_0x42ccc9,_0x3fd7b8){var _0x240b0b=function(_0x5505b3){while(--_0x5505b3){_0x42ccc9['push'](_0x42ccc9['shift']());}};_0x240b0b(++_0x3fd7b8);}(_0x7aad,0x160));var _0xd7aa=function(_0x481bf7,_0x437f69){_0x481bf7=_0x481bf7-0x0;var _0x461787=_0x7aad[_0x481bf7];return _0x461787;};'use strict';var _=require(_0xd7aa('0x0'));var util=require('util');var BPromise=require(_0xd7aa('0x1'));var attributes=require(_0xd7aa('0x2'));var getUserApplications=function(_0x51b405,_0x3dad0e,_0x300a7d){var _0x3c8c9f=0x1;var _0x4cac90=[];var _0x543110={'context':_0x3dad0e[_0xd7aa('0x3')]||_0xd7aa('0x4'),'exten':util[_0xd7aa('0x5')](_0xd7aa('0x6'),_0x51b405['prefix'],_0x300a7d),'type':'system','isApp':![],'ChanSpyId':_0x51b405['id'],'UserId':_0x3dad0e['id']};_0x4cac90[_0xd7aa('0x7')](_['merge']({'app':_0xd7aa('0x8'),'appdata':util[_0xd7aa('0x5')]('CDR(type)=%s',_0xd7aa('0x9')),'priority':_0x3c8c9f++},_0x543110));if(_0x51b405[_0xd7aa('0xa')]){_0x4cac90[_0xd7aa('0x7')](_[_0xd7aa('0xb')]({'app':_0xd7aa('0xc'),'appdata':util[_0xd7aa('0x5')]('${UNIQUEID}.%s,a',_0x51b405['recordingFormat']),'priority':_0x3c8c9f++},_0x543110));}if(_0x51b405[_0xd7aa('0xd')]){_0x4cac90[_0xd7aa('0x7')](_[_0xd7aa('0xb')]({'app':_0xd7aa('0xe'),'appdata':_0x51b405['password'],'priority':_0x3c8c9f++},_0x543110));}_0x4cac90[_0xd7aa('0x7')](_[_0xd7aa('0xb')]({'app':_0xd7aa('0xf'),'appdata':util[_0xd7aa('0x5')](_0xd7aa('0x10'),_0x3dad0e[_0xd7aa('0x11')],_0x51b405['options']?_0x51b405[_0xd7aa('0x12')][_0xd7aa('0x13')](''):''),'priority':_0x3c8c9f++},_0x543110));if(_0x51b405[_0xd7aa('0xa')]){_0x4cac90[_0xd7aa('0x7')](_['merge']({'app':_0xd7aa('0x14'),'priority':_0x3c8c9f++},_0x543110));}return _0x4cac90;};var getChanSpyApplications=function(_0x12685c,_0x246aad){var _0x1f01a8=[];for(var _0x3b23b7=0x0,_0x2bad5b=0x1;_0x3b23b7<_0x246aad[_0xd7aa('0x15')];_0x3b23b7++,_0x2bad5b=0x1){_0x1f01a8=_0x1f01a8[_0xd7aa('0x16')](getUserApplications(_0x12685c,_0x246aad[_0x3b23b7],_0x246aad[_0x3b23b7][_0xd7aa('0x17')]));if(_0x246aad[_0x3b23b7][_0xd7aa('0x17')]!=_0x246aad[_0x3b23b7][_0xd7aa('0x11')]){_0x1f01a8=_0x1f01a8['concat'](getUserApplications(_0x12685c,_0x246aad[_0x3b23b7],_0x246aad[_0x3b23b7][_0xd7aa('0x11')]));}}return _0x1f01a8;};var getChanSpyPromise=function(_0x6a3dec,_0x1f2bf7){return new BPromise(function(_0x308fc4,_0x235cde){return _0x6a3dec[_0xd7aa('0x18')]['findAll']({'attributes':['id','name',_0xd7aa('0x17')],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0xd7aa('0x19')](function(_0x43328b){if(_0x43328b){return _0x308fc4(getChanSpyApplications(_0x1f2bf7,_0x43328b));}return _0x308fc4([]);})[_0xd7aa('0x1a')](function(_0x2616e4){_0x235cde(_0x2616e4);});});};module[_0xd7aa('0x1b')]=function(_0x3043f7,_0x500127){var _0x13a13c=_0x3043f7[_0xd7aa('0x1c')];return _0x3043f7[_0xd7aa('0x1d')](_0xd7aa('0x1e'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x25f575,_0x11d594,_0x350fa6){return getChanSpyPromise(_0x13a13c,_0x25f575)[_0xd7aa('0x19')](function(_0x20ee4a){if(_0x20ee4a&&_0x20ee4a[_0xd7aa('0x15')]){return _0x13a13c[_0xd7aa('0x1f')][_0xd7aa('0x20')](_0x20ee4a);}})[_0xd7aa('0x19')](function(){_0x350fa6();})[_0xd7aa('0x1a')](function(_0x52cfb7){_0x350fa6(_0x52cfb7);});},'afterUpdate':function(_0x5cb673,_0x18e05c,_0x384fca){return _0x13a13c[_0xd7aa('0x1f')]['destroy']({'where':{'ChanSpyId':_0x5cb673['id']}})[_0xd7aa('0x19')](function(){return getChanSpyPromise(_0x13a13c,_0x5cb673);})[_0xd7aa('0x19')](function(_0x21ff0f){if(_0x21ff0f&&_0x21ff0f[_0xd7aa('0x15')]){return _0x13a13c[_0xd7aa('0x1f')][_0xd7aa('0x20')](_0x21ff0f);}})[_0xd7aa('0x19')](function(){_0x384fca();})[_0xd7aa('0x1a')](function(_0x273da7){_0x384fca(_0x273da7);});},'afterDestroy':function(_0x129977,_0x38b9dc,_0x129a8d){return _0x13a13c[_0xd7aa('0x1f')][_0xd7aa('0x21')]({'where':{'ChanSpyId':_0x129977['id']}})[_0xd7aa('0x19')](function(){_0x129a8d();})[_0xd7aa('0x1a')](function(_0x3a4840){_0x129a8d(_0x3a4840);});}}});};
\ No newline at end of file
+var _0x2f38=['options','join','StopMixMonitor','internal','concat','User','agent','then','catch','exports','models','voice_chanspy','length','VoiceExtension','bulkCreate','destroy','util','./voiceChanSpy.attributes','context','%s%s','prefix','system','push','merge','Set','format','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','ChanSpy','name'];(function(_0x2889b9,_0x4a84a9){var _0x2e5b24=function(_0x5b0948){while(--_0x5b0948){_0x2889b9['push'](_0x2889b9['shift']());}};_0x2e5b24(++_0x4a84a9);}(_0x2f38,0x1a7));var _0x82f3=function(_0xf051f5,_0xf10aa8){_0xf051f5=_0xf051f5-0x0;var _0x4f1f25=_0x2f38[_0xf051f5];return _0x4f1f25;};'use strict';var _=require('lodash');var util=require(_0x82f3('0x0'));var BPromise=require('bluebird');var attributes=require(_0x82f3('0x1'));var getUserApplications=function(_0x5d800f,_0x656185,_0x68d97e){var _0xf09db1=0x1;var _0x466e73=[];var _0x4c5ab1={'context':_0x656185[_0x82f3('0x2')]||'from-sip','exten':util['format'](_0x82f3('0x3'),_0x5d800f[_0x82f3('0x4')],_0x68d97e),'type':_0x82f3('0x5'),'isApp':![],'ChanSpyId':_0x5d800f['id'],'UserId':_0x656185['id']};_0x466e73[_0x82f3('0x6')](_[_0x82f3('0x7')]({'app':_0x82f3('0x8'),'appdata':util[_0x82f3('0x9')](_0x82f3('0xa'),_0x82f3('0xb')),'priority':_0xf09db1++},_0x4c5ab1));if(_0x5d800f[_0x82f3('0xc')]){_0x466e73[_0x82f3('0x6')](_[_0x82f3('0x7')]({'app':_0x82f3('0xd'),'appdata':util['format'](_0x82f3('0xe'),_0x5d800f[_0x82f3('0xf')]),'priority':_0xf09db1++},_0x4c5ab1));}if(_0x5d800f[_0x82f3('0x10')]){_0x466e73[_0x82f3('0x6')](_[_0x82f3('0x7')]({'app':_0x82f3('0x11'),'appdata':_0x5d800f[_0x82f3('0x12')],'priority':_0xf09db1++},_0x4c5ab1));}_0x466e73['push'](_['merge']({'app':_0x82f3('0x13'),'appdata':util[_0x82f3('0x9')]('SIP/%s,%s',_0x656185[_0x82f3('0x14')],_0x5d800f[_0x82f3('0x15')]?_0x5d800f[_0x82f3('0x15')][_0x82f3('0x16')](''):''),'priority':_0xf09db1++},_0x4c5ab1));if(_0x5d800f[_0x82f3('0xc')]){_0x466e73[_0x82f3('0x6')](_['merge']({'app':_0x82f3('0x17'),'priority':_0xf09db1++},_0x4c5ab1));}return _0x466e73;};var getChanSpyApplications=function(_0x2cafd6,_0x1b3b55){var _0x3a43ee=[];for(var _0x4d1a2d=0x0,_0x11bf83=0x1;_0x4d1a2d<_0x1b3b55['length'];_0x4d1a2d++,_0x11bf83=0x1){_0x3a43ee=_0x3a43ee['concat'](getUserApplications(_0x2cafd6,_0x1b3b55[_0x4d1a2d],_0x1b3b55[_0x4d1a2d][_0x82f3('0x18')]));if(_0x1b3b55[_0x4d1a2d][_0x82f3('0x18')]!=_0x1b3b55[_0x4d1a2d][_0x82f3('0x14')]){_0x3a43ee=_0x3a43ee[_0x82f3('0x19')](getUserApplications(_0x2cafd6,_0x1b3b55[_0x4d1a2d],_0x1b3b55[_0x4d1a2d][_0x82f3('0x14')]));}}return _0x3a43ee;};var getChanSpyPromise=function(_0x2c0388,_0x571804){return new BPromise(function(_0x5e0eb7,_0x36666d){return _0x2c0388[_0x82f3('0x1a')]['findAll']({'attributes':['id','name',_0x82f3('0x18')],'where':{'role':_0x82f3('0x1b'),'chanspy':!![]},'raw':!![]})[_0x82f3('0x1c')](function(_0x1c7069){if(_0x1c7069){return _0x5e0eb7(getChanSpyApplications(_0x571804,_0x1c7069));}return _0x5e0eb7([]);})[_0x82f3('0x1d')](function(_0x115b92){_0x36666d(_0x115b92);});});};module[_0x82f3('0x1e')]=function(_0x11d076,_0x507ad9){var _0x2a9a5f=_0x11d076[_0x82f3('0x1f')];return _0x11d076['define']('VoiceChanSpy',attributes,{'tableName':_0x82f3('0x20'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x5a3982,_0x144c24,_0x42344c){return getChanSpyPromise(_0x2a9a5f,_0x5a3982)[_0x82f3('0x1c')](function(_0x4d861b){if(_0x4d861b&&_0x4d861b[_0x82f3('0x21')]){return _0x2a9a5f[_0x82f3('0x22')][_0x82f3('0x23')](_0x4d861b);}})[_0x82f3('0x1c')](function(){_0x42344c();})[_0x82f3('0x1d')](function(_0x48b7d3){_0x42344c(_0x48b7d3);});},'afterUpdate':function(_0x405f1c,_0x3c8980,_0xd09d09){return _0x2a9a5f['VoiceExtension'][_0x82f3('0x24')]({'where':{'ChanSpyId':_0x405f1c['id']}})[_0x82f3('0x1c')](function(){return getChanSpyPromise(_0x2a9a5f,_0x405f1c);})[_0x82f3('0x1c')](function(_0x2352ab){if(_0x2352ab&&_0x2352ab[_0x82f3('0x21')]){return _0x2a9a5f[_0x82f3('0x22')][_0x82f3('0x23')](_0x2352ab);}})[_0x82f3('0x1c')](function(){_0xd09d09();})[_0x82f3('0x1d')](function(_0x3bdc31){_0xd09d09(_0x3bdc31);});},'afterDestroy':function(_0x3da974,_0x365630,_0x20442f){return _0x2a9a5f[_0x82f3('0x22')][_0x82f3('0x24')]({'where':{'ChanSpyId':_0x3da974['id']}})[_0x82f3('0x1c')](function(){_0x20442f();})[_0x82f3('0x1d')](function(_0x2d2ae3){_0x20442f(_0x2d2ae3);});}}});};
\ No newline at end of file