Built motion from commit fade34fd.|2.5.41
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 40452e6..004e570 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf2df=['MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','password','merge','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','internal','concat','User','agent','then','catch','exports','models','define','length','VoiceExtension','bulkCreate','bluebird','context','format','%s%s','prefix','push','Set','chanspy','record'];(function(_0x6f0a96,_0x44521b){var _0x435c99=function(_0x1d81a5){while(--_0x1d81a5){_0x6f0a96['push'](_0x6f0a96['shift']());}};_0x435c99(++_0x44521b);}(_0xf2df,0x7b));var _0xff2d=function(_0x3ac9b0,_0x474ac5){_0x3ac9b0=_0x3ac9b0-0x0;var _0x366321=_0xf2df[_0x3ac9b0];return _0x366321;};'use strict';var _=require('lodash');var util=require('util');var BPromise=require(_0xff2d('0x0'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x3f2d79,_0x4b26b3,_0x14393b){var _0x2fd19b=0x1;var _0xd38d9a=[];var _0x3ab841={'context':_0x4b26b3[_0xff2d('0x1')]||'from-sip','exten':util[_0xff2d('0x2')](_0xff2d('0x3'),_0x3f2d79[_0xff2d('0x4')],_0x14393b),'type':'system','isApp':![],'ChanSpyId':_0x3f2d79['id'],'UserId':_0x4b26b3['id']};_0xd38d9a[_0xff2d('0x5')](_['merge']({'app':_0xff2d('0x6'),'appdata':util[_0xff2d('0x2')]('CDR(type)=%s',_0xff2d('0x7')),'priority':_0x2fd19b++},_0x3ab841));if(_0x3f2d79[_0xff2d('0x8')]){_0xd38d9a[_0xff2d('0x5')](_['merge']({'app':_0xff2d('0x9'),'appdata':util['format'](_0xff2d('0xa'),_0x3f2d79[_0xff2d('0xb')]),'priority':_0x2fd19b++},_0x3ab841));}if(_0x3f2d79[_0xff2d('0xc')]){_0xd38d9a['push'](_['merge']({'app':'Authenticate','appdata':_0x3f2d79[_0xff2d('0xd')],'priority':_0x2fd19b++},_0x3ab841));}_0xd38d9a[_0xff2d('0x5')](_[_0xff2d('0xe')]({'app':_0xff2d('0xf'),'appdata':util[_0xff2d('0x2')](_0xff2d('0x10'),_0x4b26b3[_0xff2d('0x11')],_0x3f2d79['options']?_0x3f2d79[_0xff2d('0x12')][_0xff2d('0x13')](''):''),'priority':_0x2fd19b++},_0x3ab841));if(_0x3f2d79['record']){_0xd38d9a[_0xff2d('0x5')](_[_0xff2d('0xe')]({'app':_0xff2d('0x14'),'priority':_0x2fd19b++},_0x3ab841));}return _0xd38d9a;};var getChanSpyApplications=function(_0x1ea940,_0x559d7e){var _0x472b76=[];for(var _0x5d8b86=0x0,_0x1c0b9a=0x1;_0x5d8b86<_0x559d7e['length'];_0x5d8b86++,_0x1c0b9a=0x1){_0x472b76=_0x472b76['concat'](getUserApplications(_0x1ea940,_0x559d7e[_0x5d8b86],_0x559d7e[_0x5d8b86]['internal']));if(_0x559d7e[_0x5d8b86][_0xff2d('0x15')]!=_0x559d7e[_0x5d8b86]['name']){_0x472b76=_0x472b76[_0xff2d('0x16')](getUserApplications(_0x1ea940,_0x559d7e[_0x5d8b86],_0x559d7e[_0x5d8b86]['name']));}}return _0x472b76;};var getChanSpyPromise=function(_0xd84ac1,_0x4bd508){return new BPromise(function(_0x17e292,_0x49a810){return _0xd84ac1[_0xff2d('0x17')]['findAll']({'attributes':['id',_0xff2d('0x11'),'internal'],'where':{'role':_0xff2d('0x18'),'chanspy':!![]},'raw':!![]})[_0xff2d('0x19')](function(_0x2b7f9e){if(_0x2b7f9e){return _0x17e292(getChanSpyApplications(_0x4bd508,_0x2b7f9e));}return _0x17e292([]);})[_0xff2d('0x1a')](function(_0x23ccc5){_0x49a810(_0x23ccc5);});});};module[_0xff2d('0x1b')]=function(_0xbb0390,_0x3e0366){var _0x438c01=_0xbb0390[_0xff2d('0x1c')];return _0xbb0390[_0xff2d('0x1d')]('VoiceChanSpy',attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x55d201,_0x5641cc,_0x49cd44){return getChanSpyPromise(_0x438c01,_0x55d201)['then'](function(_0xd60f1a){if(_0xd60f1a&&_0xd60f1a[_0xff2d('0x1e')]){return _0x438c01[_0xff2d('0x1f')][_0xff2d('0x20')](_0xd60f1a);}})[_0xff2d('0x19')](function(){_0x49cd44();})[_0xff2d('0x1a')](function(_0x32996f){_0x49cd44(_0x32996f);});},'afterUpdate':function(_0x3c4782,_0x3f0bcb,_0x39bd7a){return _0x438c01[_0xff2d('0x1f')]['destroy']({'where':{'ChanSpyId':_0x3c4782['id']}})[_0xff2d('0x19')](function(){return getChanSpyPromise(_0x438c01,_0x3c4782);})[_0xff2d('0x19')](function(_0x47c82f){if(_0x47c82f&&_0x47c82f[_0xff2d('0x1e')]){return _0x438c01[_0xff2d('0x1f')][_0xff2d('0x20')](_0x47c82f);}})[_0xff2d('0x19')](function(){_0x39bd7a();})[_0xff2d('0x1a')](function(_0x6cbf7e){_0x39bd7a(_0x6cbf7e);});},'afterDestroy':function(_0x17b18a,_0x5645a5,_0x58c5d1){return _0x438c01[_0xff2d('0x1f')]['destroy']({'where':{'ChanSpyId':_0x17b18a['id']}})[_0xff2d('0x19')](function(){_0x58c5d1();})[_0xff2d('0x1a')](function(_0x20a68c){_0x58c5d1(_0x20a68c);});}}});};
\ No newline at end of file
+var _0x34da=['join','StopMixMonitor','length','concat','internal','User','findAll','then','exports','models','define','VoiceExtension','bulkCreate','catch','lodash','util','bluebird','context','from-sip','format','%s%s','prefix','push','merge','Set','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','ChanSpy','name','options'];(function(_0x58e8eb,_0x2ac0c7){var _0x168540=function(_0x47ad20){while(--_0x47ad20){_0x58e8eb['push'](_0x58e8eb['shift']());}};_0x168540(++_0x2ac0c7);}(_0x34da,0x103));var _0xa34d=function(_0x46b962,_0x50f798){_0x46b962=_0x46b962-0x0;var _0xe99238=_0x34da[_0x46b962];return _0xe99238;};'use strict';var _=require(_0xa34d('0x0'));var util=require(_0xa34d('0x1'));var BPromise=require(_0xa34d('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x43cfde,_0x3d2225,_0x21057f){var _0x2d7b6a=0x1;var _0x5e8f4d=[];var _0x25b8c5={'context':_0x3d2225[_0xa34d('0x3')]||_0xa34d('0x4'),'exten':util[_0xa34d('0x5')](_0xa34d('0x6'),_0x43cfde[_0xa34d('0x7')],_0x21057f),'type':'system','isApp':![],'ChanSpyId':_0x43cfde['id'],'UserId':_0x3d2225['id']};_0x5e8f4d[_0xa34d('0x8')](_[_0xa34d('0x9')]({'app':_0xa34d('0xa'),'appdata':util[_0xa34d('0x5')]('CDR(type)=%s',_0xa34d('0xb')),'priority':_0x2d7b6a++},_0x25b8c5));if(_0x43cfde[_0xa34d('0xc')]){_0x5e8f4d[_0xa34d('0x8')](_[_0xa34d('0x9')]({'app':_0xa34d('0xd'),'appdata':util['format'](_0xa34d('0xe'),_0x43cfde[_0xa34d('0xf')]),'priority':_0x2d7b6a++},_0x25b8c5));}if(_0x43cfde['auth']){_0x5e8f4d[_0xa34d('0x8')](_[_0xa34d('0x9')]({'app':_0xa34d('0x10'),'appdata':_0x43cfde[_0xa34d('0x11')],'priority':_0x2d7b6a++},_0x25b8c5));}_0x5e8f4d[_0xa34d('0x8')](_[_0xa34d('0x9')]({'app':_0xa34d('0x12'),'appdata':util['format']('SIP/%s,%s',_0x3d2225[_0xa34d('0x13')],_0x43cfde[_0xa34d('0x14')]?_0x43cfde[_0xa34d('0x14')][_0xa34d('0x15')](''):''),'priority':_0x2d7b6a++},_0x25b8c5));if(_0x43cfde['record']){_0x5e8f4d[_0xa34d('0x8')](_['merge']({'app':_0xa34d('0x16'),'priority':_0x2d7b6a++},_0x25b8c5));}return _0x5e8f4d;};var getChanSpyApplications=function(_0x364270,_0x2df9f5){var _0x1fa18f=[];for(var _0x4dc5c9=0x0,_0x39597b=0x1;_0x4dc5c9<_0x2df9f5[_0xa34d('0x17')];_0x4dc5c9++,_0x39597b=0x1){_0x1fa18f=_0x1fa18f[_0xa34d('0x18')](getUserApplications(_0x364270,_0x2df9f5[_0x4dc5c9],_0x2df9f5[_0x4dc5c9]['internal']));if(_0x2df9f5[_0x4dc5c9][_0xa34d('0x19')]!=_0x2df9f5[_0x4dc5c9][_0xa34d('0x13')]){_0x1fa18f=_0x1fa18f[_0xa34d('0x18')](getUserApplications(_0x364270,_0x2df9f5[_0x4dc5c9],_0x2df9f5[_0x4dc5c9][_0xa34d('0x13')]));}}return _0x1fa18f;};var getChanSpyPromise=function(_0x3966b4,_0x281b4d){return new BPromise(function(_0x435a86,_0xb8223e){return _0x3966b4[_0xa34d('0x1a')][_0xa34d('0x1b')]({'attributes':['id',_0xa34d('0x13'),'internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0xa34d('0x1c')](function(_0x431800){if(_0x431800){return _0x435a86(getChanSpyApplications(_0x281b4d,_0x431800));}return _0x435a86([]);})['catch'](function(_0x3e10ff){_0xb8223e(_0x3e10ff);});});};module[_0xa34d('0x1d')]=function(_0x4366e7,_0x261ad5){var _0x455748=_0x4366e7[_0xa34d('0x1e')];return _0x4366e7[_0xa34d('0x1f')]('VoiceChanSpy',attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x16d28d,_0x4f5be0,_0x2968ee){return getChanSpyPromise(_0x455748,_0x16d28d)[_0xa34d('0x1c')](function(_0x4ac3f2){if(_0x4ac3f2&&_0x4ac3f2['length']){return _0x455748[_0xa34d('0x20')][_0xa34d('0x21')](_0x4ac3f2);}})[_0xa34d('0x1c')](function(){_0x2968ee();})['catch'](function(_0x55382f){_0x2968ee(_0x55382f);});},'afterUpdate':function(_0xc2de01,_0x30e6d1,_0x38aa33){return _0x455748[_0xa34d('0x20')]['destroy']({'where':{'ChanSpyId':_0xc2de01['id']}})[_0xa34d('0x1c')](function(){return getChanSpyPromise(_0x455748,_0xc2de01);})[_0xa34d('0x1c')](function(_0x397411){if(_0x397411&&_0x397411[_0xa34d('0x17')]){return _0x455748[_0xa34d('0x20')][_0xa34d('0x21')](_0x397411);}})[_0xa34d('0x1c')](function(){_0x38aa33();})[_0xa34d('0x22')](function(_0x5ce772){_0x38aa33(_0x5ce772);});},'afterDestroy':function(_0x3fb4a7,_0x3d2fc5,_0x18dddf){return _0x455748[_0xa34d('0x20')]['destroy']({'where':{'ChanSpyId':_0x3fb4a7['id']}})[_0xa34d('0x1c')](function(){_0x18dddf();})[_0xa34d('0x22')](function(_0x1431cd){_0x18dddf(_0x1431cd);});}}});};
\ No newline at end of file