Built motion from commit 53172ac8.|2.6.30
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 131d489..a876195 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6165=['ChanSpy','SIP/%s,%s','name','options','join','concat','internal','User','findAll','catch','models','define','VoiceChanSpy','voice_chanspy','then','length','VoiceExtension','bulkCreate','destroy','lodash','util','./voiceChanSpy.attributes','context','format','%s%s','prefix','system','push','Set','CDR(type)=%s','record','merge','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password'];(function(_0x2f50b6,_0xd09fe3){var _0x54b027=function(_0x680941){while(--_0x680941){_0x2f50b6['push'](_0x2f50b6['shift']());}};_0x54b027(++_0xd09fe3);}(_0x6165,0x1db));var _0x5616=function(_0x531624,_0x3060d0){_0x531624=_0x531624-0x0;var _0x14c202=_0x6165[_0x531624];return _0x14c202;};'use strict';var _=require(_0x5616('0x0'));var util=require(_0x5616('0x1'));var BPromise=require('bluebird');var attributes=require(_0x5616('0x2'));var getUserApplications=function(_0x1be68c,_0x4e9e7b,_0x29d3a4){var _0x3c2fd1=0x1;var _0x12e1d1=[];var _0x300c1f={'context':_0x4e9e7b[_0x5616('0x3')]||'from-sip','exten':util[_0x5616('0x4')](_0x5616('0x5'),_0x1be68c[_0x5616('0x6')],_0x29d3a4),'type':_0x5616('0x7'),'isApp':![],'ChanSpyId':_0x1be68c['id'],'UserId':_0x4e9e7b['id']};_0x12e1d1[_0x5616('0x8')](_['merge']({'app':_0x5616('0x9'),'appdata':util[_0x5616('0x4')](_0x5616('0xa'),'chanspy'),'priority':_0x3c2fd1++},_0x300c1f));if(_0x1be68c[_0x5616('0xb')]){_0x12e1d1[_0x5616('0x8')](_[_0x5616('0xc')]({'app':_0x5616('0xd'),'appdata':util[_0x5616('0x4')](_0x5616('0xe'),_0x1be68c[_0x5616('0xf')]),'priority':_0x3c2fd1++},_0x300c1f));}if(_0x1be68c[_0x5616('0x10')]){_0x12e1d1[_0x5616('0x8')](_['merge']({'app':_0x5616('0x11'),'appdata':_0x1be68c[_0x5616('0x12')],'priority':_0x3c2fd1++},_0x300c1f));}_0x12e1d1[_0x5616('0x8')](_['merge']({'app':_0x5616('0x13'),'appdata':util['format'](_0x5616('0x14'),_0x4e9e7b[_0x5616('0x15')],_0x1be68c[_0x5616('0x16')]?_0x1be68c[_0x5616('0x16')][_0x5616('0x17')](''):''),'priority':_0x3c2fd1++},_0x300c1f));if(_0x1be68c['record']){_0x12e1d1[_0x5616('0x8')](_['merge']({'app':'StopMixMonitor','priority':_0x3c2fd1++},_0x300c1f));}return _0x12e1d1;};var getChanSpyApplications=function(_0x4f9c44,_0x5d3f04){var _0x332cd1=[];for(var _0x35b57c=0x0,_0x41602e=0x1;_0x35b57c<_0x5d3f04['length'];_0x35b57c++,_0x41602e=0x1){_0x332cd1=_0x332cd1[_0x5616('0x18')](getUserApplications(_0x4f9c44,_0x5d3f04[_0x35b57c],_0x5d3f04[_0x35b57c][_0x5616('0x19')]));if(_0x5d3f04[_0x35b57c][_0x5616('0x19')]!=_0x5d3f04[_0x35b57c][_0x5616('0x15')]){_0x332cd1=_0x332cd1['concat'](getUserApplications(_0x4f9c44,_0x5d3f04[_0x35b57c],_0x5d3f04[_0x35b57c][_0x5616('0x15')]));}}return _0x332cd1;};var getChanSpyPromise=function(_0x99f3ed,_0x9609cb){return new BPromise(function(_0x346160,_0x585d3f){return _0x99f3ed[_0x5616('0x1a')][_0x5616('0x1b')]({'attributes':['id','name','internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})['then'](function(_0xa49ac3){if(_0xa49ac3){return _0x346160(getChanSpyApplications(_0x9609cb,_0xa49ac3));}return _0x346160([]);})[_0x5616('0x1c')](function(_0x225f08){_0x585d3f(_0x225f08);});});};module['exports']=function(_0x1bb4b0,_0x3cff0c){var _0xb45208=_0x1bb4b0[_0x5616('0x1d')];return _0x1bb4b0[_0x5616('0x1e')](_0x5616('0x1f'),attributes,{'tableName':_0x5616('0x20'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x30d7e9,_0x205e97,_0x2e544a){return getChanSpyPromise(_0xb45208,_0x30d7e9)[_0x5616('0x21')](function(_0x5e374d){if(_0x5e374d&&_0x5e374d[_0x5616('0x22')]){return _0xb45208[_0x5616('0x23')][_0x5616('0x24')](_0x5e374d);}})['then'](function(){_0x2e544a();})[_0x5616('0x1c')](function(_0x595d53){_0x2e544a(_0x595d53);});},'afterUpdate':function(_0x167b25,_0x3a3c53,_0x411e54){return _0xb45208[_0x5616('0x23')][_0x5616('0x25')]({'where':{'ChanSpyId':_0x167b25['id']}})['then'](function(){return getChanSpyPromise(_0xb45208,_0x167b25);})[_0x5616('0x21')](function(_0x334720){if(_0x334720&&_0x334720['length']){return _0xb45208['VoiceExtension'][_0x5616('0x24')](_0x334720);}})[_0x5616('0x21')](function(){_0x411e54();})[_0x5616('0x1c')](function(_0xc8f154){_0x411e54(_0xc8f154);});},'afterDestroy':function(_0xce05fd,_0x96f22f,_0xee32ae){return _0xb45208[_0x5616('0x23')]['destroy']({'where':{'ChanSpyId':_0xce05fd['id']}})[_0x5616('0x21')](function(){_0xee32ae();})[_0x5616('0x1c')](function(_0x414ef5){_0xee32ae(_0x414ef5);});}}});};
\ No newline at end of file
+var _0xd062=['prefix','system','push','merge','format','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','password','ChanSpy','name','options','StopMixMonitor','length','concat','internal','User','findAll','agent','then','catch','exports','models','define','VoiceChanSpy','VoiceExtension','bulkCreate','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip'];(function(_0x101a17,_0x5d047a){var _0x3b76ee=function(_0x89be1b){while(--_0x89be1b){_0x101a17['push'](_0x101a17['shift']());}};_0x3b76ee(++_0x5d047a);}(_0xd062,0xfd));var _0x2d06=function(_0x12c0fe,_0x2af9c8){_0x12c0fe=_0x12c0fe-0x0;var _0x4ac0b7=_0xd062[_0x12c0fe];return _0x4ac0b7;};'use strict';var _=require(_0x2d06('0x0'));var util=require(_0x2d06('0x1'));var BPromise=require(_0x2d06('0x2'));var attributes=require(_0x2d06('0x3'));var getUserApplications=function(_0x4896f2,_0x155c41,_0x31217b){var _0x2f42c6=0x1;var _0x15eebf=[];var _0x8625fd={'context':_0x155c41[_0x2d06('0x4')]||_0x2d06('0x5'),'exten':util['format']('%s%s',_0x4896f2[_0x2d06('0x6')],_0x31217b),'type':_0x2d06('0x7'),'isApp':![],'ChanSpyId':_0x4896f2['id'],'UserId':_0x155c41['id']};_0x15eebf[_0x2d06('0x8')](_[_0x2d06('0x9')]({'app':'Set','appdata':util[_0x2d06('0xa')](_0x2d06('0xb'),_0x2d06('0xc')),'priority':_0x2f42c6++},_0x8625fd));if(_0x4896f2[_0x2d06('0xd')]){_0x15eebf[_0x2d06('0x8')](_[_0x2d06('0x9')]({'app':_0x2d06('0xe'),'appdata':util[_0x2d06('0xa')](_0x2d06('0xf'),_0x4896f2[_0x2d06('0x10')]),'priority':_0x2f42c6++},_0x8625fd));}if(_0x4896f2['auth']){_0x15eebf[_0x2d06('0x8')](_[_0x2d06('0x9')]({'app':'Authenticate','appdata':_0x4896f2[_0x2d06('0x11')],'priority':_0x2f42c6++},_0x8625fd));}_0x15eebf[_0x2d06('0x8')](_[_0x2d06('0x9')]({'app':_0x2d06('0x12'),'appdata':util[_0x2d06('0xa')]('SIP/%s,%s',_0x155c41[_0x2d06('0x13')],_0x4896f2[_0x2d06('0x14')]?_0x4896f2['options']['join'](''):''),'priority':_0x2f42c6++},_0x8625fd));if(_0x4896f2['record']){_0x15eebf[_0x2d06('0x8')](_['merge']({'app':_0x2d06('0x15'),'priority':_0x2f42c6++},_0x8625fd));}return _0x15eebf;};var getChanSpyApplications=function(_0x11c4c0,_0x42c835){var _0x3ca2ee=[];for(var _0x1ce378=0x0,_0x591239=0x1;_0x1ce378<_0x42c835[_0x2d06('0x16')];_0x1ce378++,_0x591239=0x1){_0x3ca2ee=_0x3ca2ee[_0x2d06('0x17')](getUserApplications(_0x11c4c0,_0x42c835[_0x1ce378],_0x42c835[_0x1ce378][_0x2d06('0x18')]));if(_0x42c835[_0x1ce378][_0x2d06('0x18')]!=_0x42c835[_0x1ce378]['name']){_0x3ca2ee=_0x3ca2ee[_0x2d06('0x17')](getUserApplications(_0x11c4c0,_0x42c835[_0x1ce378],_0x42c835[_0x1ce378]['name']));}}return _0x3ca2ee;};var getChanSpyPromise=function(_0x48d829,_0x4e26a7){return new BPromise(function(_0x5771ee,_0x21bae7){return _0x48d829[_0x2d06('0x19')][_0x2d06('0x1a')]({'attributes':['id',_0x2d06('0x13'),_0x2d06('0x18')],'where':{'role':_0x2d06('0x1b'),'chanspy':!![]},'raw':!![]})[_0x2d06('0x1c')](function(_0x23e017){if(_0x23e017){return _0x5771ee(getChanSpyApplications(_0x4e26a7,_0x23e017));}return _0x5771ee([]);})[_0x2d06('0x1d')](function(_0x10b15d){_0x21bae7(_0x10b15d);});});};module[_0x2d06('0x1e')]=function(_0x416e73,_0x1b005c){var _0x5ba465=_0x416e73[_0x2d06('0x1f')];return _0x416e73[_0x2d06('0x20')](_0x2d06('0x21'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x37df54,_0x522b91,_0x3c6467){return getChanSpyPromise(_0x5ba465,_0x37df54)[_0x2d06('0x1c')](function(_0x52c75d){if(_0x52c75d&&_0x52c75d['length']){return _0x5ba465[_0x2d06('0x22')]['bulkCreate'](_0x52c75d);}})[_0x2d06('0x1c')](function(){_0x3c6467();})[_0x2d06('0x1d')](function(_0xe8c70b){_0x3c6467(_0xe8c70b);});},'afterUpdate':function(_0x87f3dc,_0x422642,_0x52670b){return _0x5ba465[_0x2d06('0x22')]['destroy']({'where':{'ChanSpyId':_0x87f3dc['id']}})[_0x2d06('0x1c')](function(){return getChanSpyPromise(_0x5ba465,_0x87f3dc);})[_0x2d06('0x1c')](function(_0x53e6e3){if(_0x53e6e3&&_0x53e6e3[_0x2d06('0x16')]){return _0x5ba465['VoiceExtension'][_0x2d06('0x23')](_0x53e6e3);}})[_0x2d06('0x1c')](function(){_0x52670b();})[_0x2d06('0x1d')](function(_0x8ba1a7){_0x52670b(_0x8ba1a7);});},'afterDestroy':function(_0x5efe3a,_0x433caf,_0x602ce){return _0x5ba465['VoiceExtension'][_0x2d06('0x24')]({'where':{'ChanSpyId':_0x5efe3a['id']}})[_0x2d06('0x1c')](function(){_0x602ce();})['catch'](function(_0x789926){_0x602ce(_0x789926);});}}});};
\ No newline at end of file