Built motion from commit 4c579f6b.|2.5.32
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 0e9c302..25b37c1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcbe1=['${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','ChanSpy','name','options','join','record','StopMixMonitor','length','internal','agent','catch','exports','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension','then','destroy','util','from-sip','format','prefix','system','push','merge','Set','CDR(type)=%s','chanspy','MixMonitor'];(function(_0x6e7421,_0x22c58f){var _0x14d45e=function(_0x296ca5){while(--_0x296ca5){_0x6e7421['push'](_0x6e7421['shift']());}};_0x14d45e(++_0x22c58f);}(_0xcbe1,0x1a2));var _0x1cbe=function(_0xf3f58c,_0x38b821){_0xf3f58c=_0xf3f58c-0x0;var _0x53d7b6=_0xcbe1[_0xf3f58c];return _0x53d7b6;};'use strict';var _=require('lodash');var util=require(_0x1cbe('0x0'));var BPromise=require('bluebird');var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x494fac,_0x52a8ca,_0x2e51c7){var _0x1647e8=0x1;var _0x502977=[];var _0x1ba56c={'context':_0x52a8ca['context']||_0x1cbe('0x1'),'exten':util[_0x1cbe('0x2')]('%s%s',_0x494fac[_0x1cbe('0x3')],_0x2e51c7),'type':_0x1cbe('0x4'),'isApp':![],'ChanSpyId':_0x494fac['id'],'UserId':_0x52a8ca['id']};_0x502977[_0x1cbe('0x5')](_[_0x1cbe('0x6')]({'app':_0x1cbe('0x7'),'appdata':util[_0x1cbe('0x2')](_0x1cbe('0x8'),_0x1cbe('0x9')),'priority':_0x1647e8++},_0x1ba56c));if(_0x494fac['record']){_0x502977[_0x1cbe('0x5')](_['merge']({'app':_0x1cbe('0xa'),'appdata':util[_0x1cbe('0x2')](_0x1cbe('0xb'),_0x494fac[_0x1cbe('0xc')]),'priority':_0x1647e8++},_0x1ba56c));}if(_0x494fac['auth']){_0x502977[_0x1cbe('0x5')](_['merge']({'app':_0x1cbe('0xd'),'appdata':_0x494fac[_0x1cbe('0xe')],'priority':_0x1647e8++},_0x1ba56c));}_0x502977['push'](_[_0x1cbe('0x6')]({'app':_0x1cbe('0xf'),'appdata':util[_0x1cbe('0x2')]('SIP/%s,%s',_0x52a8ca[_0x1cbe('0x10')],_0x494fac[_0x1cbe('0x11')]?_0x494fac[_0x1cbe('0x11')][_0x1cbe('0x12')](''):''),'priority':_0x1647e8++},_0x1ba56c));if(_0x494fac[_0x1cbe('0x13')]){_0x502977[_0x1cbe('0x5')](_[_0x1cbe('0x6')]({'app':_0x1cbe('0x14'),'priority':_0x1647e8++},_0x1ba56c));}return _0x502977;};var getChanSpyApplications=function(_0x109cd7,_0x41eec7){var _0x4fd646=[];for(var _0x228488=0x0,_0x3a43cc=0x1;_0x228488<_0x41eec7[_0x1cbe('0x15')];_0x228488++,_0x3a43cc=0x1){_0x4fd646=_0x4fd646['concat'](getUserApplications(_0x109cd7,_0x41eec7[_0x228488],_0x41eec7[_0x228488][_0x1cbe('0x16')]));if(_0x41eec7[_0x228488][_0x1cbe('0x16')]!=_0x41eec7[_0x228488][_0x1cbe('0x10')]){_0x4fd646=_0x4fd646['concat'](getUserApplications(_0x109cd7,_0x41eec7[_0x228488],_0x41eec7[_0x228488]['name']));}}return _0x4fd646;};var getChanSpyPromise=function(_0x30a154,_0x75e87a){return new BPromise(function(_0x20aa62,_0x1c579b){return _0x30a154['User']['findAll']({'attributes':['id',_0x1cbe('0x10'),_0x1cbe('0x16')],'where':{'role':_0x1cbe('0x17'),'chanspy':!![]},'raw':!![]})['then'](function(_0x5b40ea){if(_0x5b40ea){return _0x20aa62(getChanSpyApplications(_0x75e87a,_0x5b40ea));}return _0x20aa62([]);})[_0x1cbe('0x18')](function(_0x4aff8d){_0x1c579b(_0x4aff8d);});});};module[_0x1cbe('0x19')]=function(_0x192a76,_0x16f466){var _0x1790b1=_0x192a76[_0x1cbe('0x1a')];return _0x192a76[_0x1cbe('0x1b')](_0x1cbe('0x1c'),attributes,{'tableName':_0x1cbe('0x1d'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xbdbfdb,_0x4c7a82,_0x23a5f3){return getChanSpyPromise(_0x1790b1,_0xbdbfdb)['then'](function(_0x1fb6aa){if(_0x1fb6aa&&_0x1fb6aa[_0x1cbe('0x15')]){return _0x1790b1[_0x1cbe('0x1e')]['bulkCreate'](_0x1fb6aa);}})[_0x1cbe('0x1f')](function(){_0x23a5f3();})[_0x1cbe('0x18')](function(_0x1b391d){_0x23a5f3(_0x1b391d);});},'afterUpdate':function(_0x17cc57,_0xd9bb05,_0x53bcee){return _0x1790b1['VoiceExtension'][_0x1cbe('0x20')]({'where':{'ChanSpyId':_0x17cc57['id']}})[_0x1cbe('0x1f')](function(){return getChanSpyPromise(_0x1790b1,_0x17cc57);})[_0x1cbe('0x1f')](function(_0x5d781d){if(_0x5d781d&&_0x5d781d['length']){return _0x1790b1[_0x1cbe('0x1e')]['bulkCreate'](_0x5d781d);}})[_0x1cbe('0x1f')](function(){_0x53bcee();})['catch'](function(_0x7d95b9){_0x53bcee(_0x7d95b9);});},'afterDestroy':function(_0x9b12c4,_0x3a937e,_0x37a4f5){return _0x1790b1['VoiceExtension'][_0x1cbe('0x20')]({'where':{'ChanSpyId':_0x9b12c4['id']}})[_0x1cbe('0x1f')](function(){_0x37a4f5();})[_0x1cbe('0x18')](function(_0x8b1783){_0x37a4f5(_0x8b1783);});}}});};
\ No newline at end of file
+var _0x6768=['concat','internal','User','findAll','then','catch','exports','define','VoiceChanSpy','voice_chanspy','VoiceExtension','bulkCreate','destroy','lodash','util','bluebird','context','from-sip','prefix','system','push','merge','Set','CDR(type)=%s','chanspy','MixMonitor','format','${UNIQUEID}.%s,a','auth','Authenticate','ChanSpy','SIP/%s,%s','name','options','join','record','StopMixMonitor','length'];(function(_0x4a4fb8,_0x1c8af){var _0x1d27c8=function(_0x56ae4f){while(--_0x56ae4f){_0x4a4fb8['push'](_0x4a4fb8['shift']());}};_0x1d27c8(++_0x1c8af);}(_0x6768,0xa5));var _0x8676=function(_0x1dcd38,_0x4199d0){_0x1dcd38=_0x1dcd38-0x0;var _0x5743c2=_0x6768[_0x1dcd38];return _0x5743c2;};'use strict';var _=require(_0x8676('0x0'));var util=require(_0x8676('0x1'));var BPromise=require(_0x8676('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x5c3470,_0x1ad07f,_0x3fc320){var _0x455fd0=0x1;var _0x11608a=[];var _0x144e31={'context':_0x1ad07f[_0x8676('0x3')]||_0x8676('0x4'),'exten':util['format']('%s%s',_0x5c3470[_0x8676('0x5')],_0x3fc320),'type':_0x8676('0x6'),'isApp':![],'ChanSpyId':_0x5c3470['id'],'UserId':_0x1ad07f['id']};_0x11608a[_0x8676('0x7')](_[_0x8676('0x8')]({'app':_0x8676('0x9'),'appdata':util['format'](_0x8676('0xa'),_0x8676('0xb')),'priority':_0x455fd0++},_0x144e31));if(_0x5c3470['record']){_0x11608a[_0x8676('0x7')](_[_0x8676('0x8')]({'app':_0x8676('0xc'),'appdata':util[_0x8676('0xd')](_0x8676('0xe'),_0x5c3470['recordingFormat']),'priority':_0x455fd0++},_0x144e31));}if(_0x5c3470[_0x8676('0xf')]){_0x11608a['push'](_[_0x8676('0x8')]({'app':_0x8676('0x10'),'appdata':_0x5c3470['password'],'priority':_0x455fd0++},_0x144e31));}_0x11608a[_0x8676('0x7')](_[_0x8676('0x8')]({'app':_0x8676('0x11'),'appdata':util[_0x8676('0xd')](_0x8676('0x12'),_0x1ad07f[_0x8676('0x13')],_0x5c3470[_0x8676('0x14')]?_0x5c3470[_0x8676('0x14')][_0x8676('0x15')](''):''),'priority':_0x455fd0++},_0x144e31));if(_0x5c3470[_0x8676('0x16')]){_0x11608a['push'](_[_0x8676('0x8')]({'app':_0x8676('0x17'),'priority':_0x455fd0++},_0x144e31));}return _0x11608a;};var getChanSpyApplications=function(_0x2d05da,_0x229e7c){var _0x14e499=[];for(var _0x4180ab=0x0,_0x515a32=0x1;_0x4180ab<_0x229e7c[_0x8676('0x18')];_0x4180ab++,_0x515a32=0x1){_0x14e499=_0x14e499[_0x8676('0x19')](getUserApplications(_0x2d05da,_0x229e7c[_0x4180ab],_0x229e7c[_0x4180ab][_0x8676('0x1a')]));if(_0x229e7c[_0x4180ab][_0x8676('0x1a')]!=_0x229e7c[_0x4180ab]['name']){_0x14e499=_0x14e499[_0x8676('0x19')](getUserApplications(_0x2d05da,_0x229e7c[_0x4180ab],_0x229e7c[_0x4180ab][_0x8676('0x13')]));}}return _0x14e499;};var getChanSpyPromise=function(_0x3cc975,_0x341410){return new BPromise(function(_0x2d3cda,_0x544b9a){return _0x3cc975[_0x8676('0x1b')][_0x8676('0x1c')]({'attributes':['id','name','internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x8676('0x1d')](function(_0x4f6ff4){if(_0x4f6ff4){return _0x2d3cda(getChanSpyApplications(_0x341410,_0x4f6ff4));}return _0x2d3cda([]);})[_0x8676('0x1e')](function(_0x35691f){_0x544b9a(_0x35691f);});});};module[_0x8676('0x1f')]=function(_0x4348fc,_0x2000c7){var _0x203b1a=_0x4348fc['models'];return _0x4348fc[_0x8676('0x20')](_0x8676('0x21'),attributes,{'tableName':_0x8676('0x22'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1a6baa,_0x334e6b,_0x5cde59){return getChanSpyPromise(_0x203b1a,_0x1a6baa)[_0x8676('0x1d')](function(_0x4b26fc){if(_0x4b26fc&&_0x4b26fc[_0x8676('0x18')]){return _0x203b1a[_0x8676('0x23')][_0x8676('0x24')](_0x4b26fc);}})['then'](function(){_0x5cde59();})['catch'](function(_0x4b0337){_0x5cde59(_0x4b0337);});},'afterUpdate':function(_0x3b6c4,_0x2c01ca,_0x357f6e){return _0x203b1a[_0x8676('0x23')][_0x8676('0x25')]({'where':{'ChanSpyId':_0x3b6c4['id']}})[_0x8676('0x1d')](function(){return getChanSpyPromise(_0x203b1a,_0x3b6c4);})['then'](function(_0x47e71f){if(_0x47e71f&&_0x47e71f['length']){return _0x203b1a[_0x8676('0x23')][_0x8676('0x24')](_0x47e71f);}})['then'](function(){_0x357f6e();})['catch'](function(_0x5b9cde){_0x357f6e(_0x5b9cde);});},'afterDestroy':function(_0x4e01d6,_0x3e4c2c,_0x23eee9){return _0x203b1a['VoiceExtension'][_0x8676('0x25')]({'where':{'ChanSpyId':_0x4e01d6['id']}})[_0x8676('0x1d')](function(){_0x23eee9();})['catch'](function(_0x5c67c9){_0x23eee9(_0x5c67c9);});}}});};
\ No newline at end of file