Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 88fe746..c74103c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5c9c=['merge','MixMonitor','format','${UNIQUEID}.%s,a','recordingFormat','auth','ChanSpy','SIP/%s,%s','name','options','StopMixMonitor','concat','internal','User','findAll','agent','then','catch','models','VoiceChanSpy','voice_chanspy','length','VoiceExtension','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','%s%s','prefix','push','CDR(type)=%s','record'];(function(_0x15563e,_0x1357f7){var _0x1150c3=function(_0x1383c9){while(--_0x1383c9){_0x15563e['push'](_0x15563e['shift']());}};_0x1150c3(++_0x1357f7);}(_0x5c9c,0x1d1));var _0xc5c9=function(_0x9ead9f,_0x5b5e47){_0x9ead9f=_0x9ead9f-0x0;var _0x3358a1=_0x5c9c[_0x9ead9f];return _0x3358a1;};'use strict';var _=require(_0xc5c9('0x0'));var util=require(_0xc5c9('0x1'));var BPromise=require(_0xc5c9('0x2'));var attributes=require(_0xc5c9('0x3'));var getUserApplications=function(_0x24fc2c,_0x543896,_0x1d3ab9){var _0x1decca=0x1;var _0x3476e4=[];var _0x3c8342={'context':_0x543896[_0xc5c9('0x4')]||_0xc5c9('0x5'),'exten':util['format'](_0xc5c9('0x6'),_0x24fc2c[_0xc5c9('0x7')],_0x1d3ab9),'type':'system','isApp':![],'ChanSpyId':_0x24fc2c['id'],'UserId':_0x543896['id']};_0x3476e4[_0xc5c9('0x8')](_['merge']({'app':'Set','appdata':util['format'](_0xc5c9('0x9'),'chanspy'),'priority':_0x1decca++},_0x3c8342));if(_0x24fc2c[_0xc5c9('0xa')]){_0x3476e4[_0xc5c9('0x8')](_[_0xc5c9('0xb')]({'app':_0xc5c9('0xc'),'appdata':util[_0xc5c9('0xd')](_0xc5c9('0xe'),_0x24fc2c[_0xc5c9('0xf')]),'priority':_0x1decca++},_0x3c8342));}if(_0x24fc2c[_0xc5c9('0x10')]){_0x3476e4[_0xc5c9('0x8')](_['merge']({'app':'Authenticate','appdata':_0x24fc2c['password'],'priority':_0x1decca++},_0x3c8342));}_0x3476e4[_0xc5c9('0x8')](_[_0xc5c9('0xb')]({'app':_0xc5c9('0x11'),'appdata':util['format'](_0xc5c9('0x12'),_0x543896[_0xc5c9('0x13')],_0x24fc2c[_0xc5c9('0x14')]?_0x24fc2c[_0xc5c9('0x14')]['join'](''):''),'priority':_0x1decca++},_0x3c8342));if(_0x24fc2c[_0xc5c9('0xa')]){_0x3476e4['push'](_[_0xc5c9('0xb')]({'app':_0xc5c9('0x15'),'priority':_0x1decca++},_0x3c8342));}return _0x3476e4;};var getChanSpyApplications=function(_0x4fdf32,_0x35c701){var _0x70a450=[];for(var _0x162e58=0x0,_0x125215=0x1;_0x162e58<_0x35c701['length'];_0x162e58++,_0x125215=0x1){_0x70a450=_0x70a450[_0xc5c9('0x16')](getUserApplications(_0x4fdf32,_0x35c701[_0x162e58],_0x35c701[_0x162e58][_0xc5c9('0x17')]));if(_0x35c701[_0x162e58]['internal']!=_0x35c701[_0x162e58][_0xc5c9('0x13')]){_0x70a450=_0x70a450[_0xc5c9('0x16')](getUserApplications(_0x4fdf32,_0x35c701[_0x162e58],_0x35c701[_0x162e58][_0xc5c9('0x13')]));}}return _0x70a450;};var getChanSpyPromise=function(_0x2d2668,_0x38f18e){return new BPromise(function(_0x4e2f42,_0x1968d5){return _0x2d2668[_0xc5c9('0x18')][_0xc5c9('0x19')]({'attributes':['id',_0xc5c9('0x13'),_0xc5c9('0x17')],'where':{'role':_0xc5c9('0x1a'),'chanspy':!![]},'raw':!![]})[_0xc5c9('0x1b')](function(_0x1e90fe){if(_0x1e90fe){return _0x4e2f42(getChanSpyApplications(_0x38f18e,_0x1e90fe));}return _0x4e2f42([]);})[_0xc5c9('0x1c')](function(_0x381e61){_0x1968d5(_0x381e61);});});};module['exports']=function(_0x55717f,_0xa87e9){var _0xa82302=_0x55717f[_0xc5c9('0x1d')];return _0x55717f['define'](_0xc5c9('0x1e'),attributes,{'tableName':_0xc5c9('0x1f'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x3d9d91,_0x263922,_0x41cc1e){return getChanSpyPromise(_0xa82302,_0x3d9d91)[_0xc5c9('0x1b')](function(_0x596453){if(_0x596453&&_0x596453[_0xc5c9('0x20')]){return _0xa82302['VoiceExtension']['bulkCreate'](_0x596453);}})[_0xc5c9('0x1b')](function(){_0x41cc1e();})[_0xc5c9('0x1c')](function(_0x3c01bd){_0x41cc1e(_0x3c01bd);});},'afterUpdate':function(_0x7eb72d,_0x59ff53,_0x294ff5){return _0xa82302[_0xc5c9('0x21')]['destroy']({'where':{'ChanSpyId':_0x7eb72d['id']}})['then'](function(){return getChanSpyPromise(_0xa82302,_0x7eb72d);})[_0xc5c9('0x1b')](function(_0x51ef49){if(_0x51ef49&&_0x51ef49[_0xc5c9('0x20')]){return _0xa82302[_0xc5c9('0x21')]['bulkCreate'](_0x51ef49);}})[_0xc5c9('0x1b')](function(){_0x294ff5();})['catch'](function(_0x4d53a5){_0x294ff5(_0x4d53a5);});},'afterDestroy':function(_0x1c2869,_0x72f3c1,_0x139c48){return _0xa82302[_0xc5c9('0x21')]['destroy']({'where':{'ChanSpyId':_0x1c2869['id']}})[_0xc5c9('0x1b')](function(){_0x139c48();})[_0xc5c9('0x1c')](function(_0x40551f){_0x139c48(_0x40551f);});}}});};
\ No newline at end of file
+var _0x4e61=['${UNIQUEID}.%s,a','Authenticate','ChanSpy','name','options','join','StopMixMonitor','internal','concat','User','findAll','agent','then','catch','exports','models','define','VoiceChanSpy','voice_chanspy','length','VoiceExtension','bulkCreate','destroy','lodash','util','bluebird','context','from-sip','format','%s%s','prefix','system','push','merge','Set','CDR(type)=%s','chanspy','record','MixMonitor'];(function(_0x3bdace,_0x42132d){var _0x2be2ae=function(_0x44f1a2){while(--_0x44f1a2){_0x3bdace['push'](_0x3bdace['shift']());}};_0x2be2ae(++_0x42132d);}(_0x4e61,0x8c));var _0x14e6=function(_0x52c8e8,_0x5ee20d){_0x52c8e8=_0x52c8e8-0x0;var _0x31bb1a=_0x4e61[_0x52c8e8];return _0x31bb1a;};'use strict';var _=require(_0x14e6('0x0'));var util=require(_0x14e6('0x1'));var BPromise=require(_0x14e6('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x53cf7e,_0x1fc8bf,_0x3ff2fb){var _0x1769fa=0x1;var _0xdcdb2a=[];var _0x1cef29={'context':_0x1fc8bf[_0x14e6('0x3')]||_0x14e6('0x4'),'exten':util[_0x14e6('0x5')](_0x14e6('0x6'),_0x53cf7e[_0x14e6('0x7')],_0x3ff2fb),'type':_0x14e6('0x8'),'isApp':![],'ChanSpyId':_0x53cf7e['id'],'UserId':_0x1fc8bf['id']};_0xdcdb2a[_0x14e6('0x9')](_[_0x14e6('0xa')]({'app':_0x14e6('0xb'),'appdata':util[_0x14e6('0x5')](_0x14e6('0xc'),_0x14e6('0xd')),'priority':_0x1769fa++},_0x1cef29));if(_0x53cf7e[_0x14e6('0xe')]){_0xdcdb2a['push'](_[_0x14e6('0xa')]({'app':_0x14e6('0xf'),'appdata':util[_0x14e6('0x5')](_0x14e6('0x10'),_0x53cf7e['recordingFormat']),'priority':_0x1769fa++},_0x1cef29));}if(_0x53cf7e['auth']){_0xdcdb2a['push'](_['merge']({'app':_0x14e6('0x11'),'appdata':_0x53cf7e['password'],'priority':_0x1769fa++},_0x1cef29));}_0xdcdb2a['push'](_[_0x14e6('0xa')]({'app':_0x14e6('0x12'),'appdata':util[_0x14e6('0x5')]('SIP/%s,%s',_0x1fc8bf[_0x14e6('0x13')],_0x53cf7e[_0x14e6('0x14')]?_0x53cf7e[_0x14e6('0x14')][_0x14e6('0x15')](''):''),'priority':_0x1769fa++},_0x1cef29));if(_0x53cf7e[_0x14e6('0xe')]){_0xdcdb2a['push'](_[_0x14e6('0xa')]({'app':_0x14e6('0x16'),'priority':_0x1769fa++},_0x1cef29));}return _0xdcdb2a;};var getChanSpyApplications=function(_0x753064,_0x3e46c0){var _0x41dc78=[];for(var _0x4d6d42=0x0,_0x34aec2=0x1;_0x4d6d42<_0x3e46c0['length'];_0x4d6d42++,_0x34aec2=0x1){_0x41dc78=_0x41dc78['concat'](getUserApplications(_0x753064,_0x3e46c0[_0x4d6d42],_0x3e46c0[_0x4d6d42]['internal']));if(_0x3e46c0[_0x4d6d42][_0x14e6('0x17')]!=_0x3e46c0[_0x4d6d42][_0x14e6('0x13')]){_0x41dc78=_0x41dc78[_0x14e6('0x18')](getUserApplications(_0x753064,_0x3e46c0[_0x4d6d42],_0x3e46c0[_0x4d6d42][_0x14e6('0x13')]));}}return _0x41dc78;};var getChanSpyPromise=function(_0x5642d4,_0x52693c){return new BPromise(function(_0x2a26cc,_0xaa4597){return _0x5642d4[_0x14e6('0x19')][_0x14e6('0x1a')]({'attributes':['id',_0x14e6('0x13'),_0x14e6('0x17')],'where':{'role':_0x14e6('0x1b'),'chanspy':!![]},'raw':!![]})[_0x14e6('0x1c')](function(_0x27a20c){if(_0x27a20c){return _0x2a26cc(getChanSpyApplications(_0x52693c,_0x27a20c));}return _0x2a26cc([]);})[_0x14e6('0x1d')](function(_0x20ea17){_0xaa4597(_0x20ea17);});});};module[_0x14e6('0x1e')]=function(_0x244bc7,_0x1bc964){var _0x262450=_0x244bc7[_0x14e6('0x1f')];return _0x244bc7[_0x14e6('0x20')](_0x14e6('0x21'),attributes,{'tableName':_0x14e6('0x22'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x378128,_0x2e1064,_0x4a5084){return getChanSpyPromise(_0x262450,_0x378128)[_0x14e6('0x1c')](function(_0x2a3807){if(_0x2a3807&&_0x2a3807[_0x14e6('0x23')]){return _0x262450[_0x14e6('0x24')][_0x14e6('0x25')](_0x2a3807);}})[_0x14e6('0x1c')](function(){_0x4a5084();})[_0x14e6('0x1d')](function(_0x529bb7){_0x4a5084(_0x529bb7);});},'afterUpdate':function(_0x3d9e66,_0x503174,_0x593980){return _0x262450['VoiceExtension'][_0x14e6('0x26')]({'where':{'ChanSpyId':_0x3d9e66['id']}})['then'](function(){return getChanSpyPromise(_0x262450,_0x3d9e66);})[_0x14e6('0x1c')](function(_0x1aef5d){if(_0x1aef5d&&_0x1aef5d[_0x14e6('0x23')]){return _0x262450['VoiceExtension'][_0x14e6('0x25')](_0x1aef5d);}})[_0x14e6('0x1c')](function(){_0x593980();})[_0x14e6('0x1d')](function(_0x5946de){_0x593980(_0x5946de);});},'afterDestroy':function(_0x1e21a3,_0x1e718a,_0x305105){return _0x262450[_0x14e6('0x24')]['destroy']({'where':{'ChanSpyId':_0x1e21a3['id']}})[_0x14e6('0x1c')](function(){_0x305105();})['catch'](function(_0x3e37d3){_0x305105(_0x3e37d3);});}}});};
\ No newline at end of file