Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index e4b1e4b..7619455 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1a75=['MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','SIP/%s,%s','options','join','internal','name','concat','User','findAll','then','catch','exports','models','define','VoiceChanSpy','length','VoiceExtension','bulkCreate','destroy','lodash','bluebird','./voiceChanSpy.attributes','from-sip','format','system','push','merge','Set','CDR(type)=%s','chanspy','record'];(function(_0x5ee735,_0xcb0a5d){var _0x5d44bb=function(_0x4dfd57){while(--_0x4dfd57){_0x5ee735['push'](_0x5ee735['shift']());}};_0x5d44bb(++_0xcb0a5d);}(_0x1a75,0x180));var _0x51a7=function(_0x3b430e,_0x7f97d8){_0x3b430e=_0x3b430e-0x0;var _0x140c58=_0x1a75[_0x3b430e];return _0x140c58;};'use strict';var _=require(_0x51a7('0x0'));var util=require('util');var BPromise=require(_0x51a7('0x1'));var attributes=require(_0x51a7('0x2'));var getUserApplications=function(_0x5818d6,_0xdcb653,_0x17703b){var _0x4f80fb=0x1;var _0x1314a2=[];var _0x353446={'context':_0xdcb653['context']||_0x51a7('0x3'),'exten':util[_0x51a7('0x4')]('%s%s',_0x5818d6['prefix'],_0x17703b),'type':_0x51a7('0x5'),'isApp':![],'ChanSpyId':_0x5818d6['id'],'UserId':_0xdcb653['id']};_0x1314a2[_0x51a7('0x6')](_[_0x51a7('0x7')]({'app':_0x51a7('0x8'),'appdata':util['format'](_0x51a7('0x9'),_0x51a7('0xa')),'priority':_0x4f80fb++},_0x353446));if(_0x5818d6[_0x51a7('0xb')]){_0x1314a2[_0x51a7('0x6')](_[_0x51a7('0x7')]({'app':_0x51a7('0xc'),'appdata':util[_0x51a7('0x4')](_0x51a7('0xd'),_0x5818d6[_0x51a7('0xe')]),'priority':_0x4f80fb++},_0x353446));}if(_0x5818d6[_0x51a7('0xf')]){_0x1314a2[_0x51a7('0x6')](_[_0x51a7('0x7')]({'app':_0x51a7('0x10'),'appdata':_0x5818d6[_0x51a7('0x11')],'priority':_0x4f80fb++},_0x353446));}_0x1314a2[_0x51a7('0x6')](_[_0x51a7('0x7')]({'app':'ChanSpy','appdata':util[_0x51a7('0x4')](_0x51a7('0x12'),_0xdcb653['name'],_0x5818d6[_0x51a7('0x13')]?_0x5818d6['options'][_0x51a7('0x14')](''):''),'priority':_0x4f80fb++},_0x353446));if(_0x5818d6[_0x51a7('0xb')]){_0x1314a2[_0x51a7('0x6')](_[_0x51a7('0x7')]({'app':'StopMixMonitor','priority':_0x4f80fb++},_0x353446));}return _0x1314a2;};var getChanSpyApplications=function(_0xbe69ce,_0x4775d7){var _0x20003e=[];for(var _0xcfb8e9=0x0,_0x5f4360=0x1;_0xcfb8e9<_0x4775d7['length'];_0xcfb8e9++,_0x5f4360=0x1){_0x20003e=_0x20003e['concat'](getUserApplications(_0xbe69ce,_0x4775d7[_0xcfb8e9],_0x4775d7[_0xcfb8e9][_0x51a7('0x15')]));if(_0x4775d7[_0xcfb8e9][_0x51a7('0x15')]!=_0x4775d7[_0xcfb8e9][_0x51a7('0x16')]){_0x20003e=_0x20003e[_0x51a7('0x17')](getUserApplications(_0xbe69ce,_0x4775d7[_0xcfb8e9],_0x4775d7[_0xcfb8e9]['name']));}}return _0x20003e;};var getChanSpyPromise=function(_0x46176f,_0x53b60b){return new BPromise(function(_0x1eb1a8,_0x1e97aa){return _0x46176f[_0x51a7('0x18')][_0x51a7('0x19')]({'attributes':['id','name',_0x51a7('0x15')],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x51a7('0x1a')](function(_0x42ead2){if(_0x42ead2){return _0x1eb1a8(getChanSpyApplications(_0x53b60b,_0x42ead2));}return _0x1eb1a8([]);})[_0x51a7('0x1b')](function(_0x290849){_0x1e97aa(_0x290849);});});};module[_0x51a7('0x1c')]=function(_0xecb943,_0x5e1dfb){var _0x4f71c9=_0xecb943[_0x51a7('0x1d')];return _0xecb943[_0x51a7('0x1e')](_0x51a7('0x1f'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xa7a1c5,_0x4d1fb6,_0x14092f){return getChanSpyPromise(_0x4f71c9,_0xa7a1c5)[_0x51a7('0x1a')](function(_0x24a657){if(_0x24a657&&_0x24a657[_0x51a7('0x20')]){return _0x4f71c9[_0x51a7('0x21')][_0x51a7('0x22')](_0x24a657);}})['then'](function(){_0x14092f();})[_0x51a7('0x1b')](function(_0xf6153b){_0x14092f(_0xf6153b);});},'afterUpdate':function(_0x45b468,_0x210fc0,_0x3a2c02){return _0x4f71c9['VoiceExtension'][_0x51a7('0x23')]({'where':{'ChanSpyId':_0x45b468['id']}})[_0x51a7('0x1a')](function(){return getChanSpyPromise(_0x4f71c9,_0x45b468);})[_0x51a7('0x1a')](function(_0xb80192){if(_0xb80192&&_0xb80192['length']){return _0x4f71c9[_0x51a7('0x21')][_0x51a7('0x22')](_0xb80192);}})['then'](function(){_0x3a2c02();})['catch'](function(_0x59182d){_0x3a2c02(_0x59182d);});},'afterDestroy':function(_0x3f32a6,_0x1637e2,_0x59286e){return _0x4f71c9[_0x51a7('0x21')][_0x51a7('0x23')]({'where':{'ChanSpyId':_0x3f32a6['id']}})[_0x51a7('0x1a')](function(){_0x59286e();})[_0x51a7('0x1b')](function(_0x46c642){_0x59286e(_0x46c642);});}}});};
\ No newline at end of file
+var _0xe401=['util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','prefix','merge','Set','CDR(type)=%s','push','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','length','concat','findAll','agent','then','catch','exports','models','define','voice_chanspy','VoiceExtension','lodash'];(function(_0x12ea52,_0x496229){var _0xb8b08=function(_0x2ed77d){while(--_0x2ed77d){_0x12ea52['push'](_0x12ea52['shift']());}};_0xb8b08(++_0x496229);}(_0xe401,0x117));var _0x1e40=function(_0x3393cb,_0x38e8a3){_0x3393cb=_0x3393cb-0x0;var _0x508cb7=_0xe401[_0x3393cb];return _0x508cb7;};'use strict';var _=require(_0x1e40('0x0'));var util=require(_0x1e40('0x1'));var BPromise=require(_0x1e40('0x2'));var attributes=require(_0x1e40('0x3'));var getUserApplications=function(_0x50a4f2,_0x2ac12f,_0x2b337e){var _0x4d0ee1=0x1;var _0x57f93a=[];var _0x327d20={'context':_0x2ac12f[_0x1e40('0x4')]||_0x1e40('0x5'),'exten':util[_0x1e40('0x6')](_0x1e40('0x7'),_0x50a4f2[_0x1e40('0x8')],_0x2b337e),'type':'system','isApp':![],'ChanSpyId':_0x50a4f2['id'],'UserId':_0x2ac12f['id']};_0x57f93a['push'](_[_0x1e40('0x9')]({'app':_0x1e40('0xa'),'appdata':util[_0x1e40('0x6')](_0x1e40('0xb'),'chanspy'),'priority':_0x4d0ee1++},_0x327d20));if(_0x50a4f2['record']){_0x57f93a[_0x1e40('0xc')](_['merge']({'app':_0x1e40('0xd'),'appdata':util[_0x1e40('0x6')](_0x1e40('0xe'),_0x50a4f2[_0x1e40('0xf')]),'priority':_0x4d0ee1++},_0x327d20));}if(_0x50a4f2[_0x1e40('0x10')]){_0x57f93a['push'](_[_0x1e40('0x9')]({'app':_0x1e40('0x11'),'appdata':_0x50a4f2['password'],'priority':_0x4d0ee1++},_0x327d20));}_0x57f93a[_0x1e40('0xc')](_['merge']({'app':_0x1e40('0x12'),'appdata':util['format'](_0x1e40('0x13'),_0x2ac12f[_0x1e40('0x14')],_0x50a4f2[_0x1e40('0x15')]?_0x50a4f2[_0x1e40('0x15')][_0x1e40('0x16')](''):''),'priority':_0x4d0ee1++},_0x327d20));if(_0x50a4f2['record']){_0x57f93a[_0x1e40('0xc')](_[_0x1e40('0x9')]({'app':_0x1e40('0x17'),'priority':_0x4d0ee1++},_0x327d20));}return _0x57f93a;};var getChanSpyApplications=function(_0x7b1db7,_0x251700){var _0x582c91=[];for(var _0x11291f=0x0,_0x1cc1c7=0x1;_0x11291f<_0x251700[_0x1e40('0x18')];_0x11291f++,_0x1cc1c7=0x1){_0x582c91=_0x582c91[_0x1e40('0x19')](getUserApplications(_0x7b1db7,_0x251700[_0x11291f],_0x251700[_0x11291f]['internal']));if(_0x251700[_0x11291f]['internal']!=_0x251700[_0x11291f][_0x1e40('0x14')]){_0x582c91=_0x582c91[_0x1e40('0x19')](getUserApplications(_0x7b1db7,_0x251700[_0x11291f],_0x251700[_0x11291f]['name']));}}return _0x582c91;};var getChanSpyPromise=function(_0x248251,_0x4d0323){return new BPromise(function(_0x64e502,_0x5668c0){return _0x248251['User'][_0x1e40('0x1a')]({'attributes':['id','name','internal'],'where':{'role':_0x1e40('0x1b'),'chanspy':!![]},'raw':!![]})[_0x1e40('0x1c')](function(_0x57a099){if(_0x57a099){return _0x64e502(getChanSpyApplications(_0x4d0323,_0x57a099));}return _0x64e502([]);})[_0x1e40('0x1d')](function(_0x53f2ef){_0x5668c0(_0x53f2ef);});});};module[_0x1e40('0x1e')]=function(_0xf1266,_0x58c394){var _0x4d76d6=_0xf1266[_0x1e40('0x1f')];return _0xf1266[_0x1e40('0x20')]('VoiceChanSpy',attributes,{'tableName':_0x1e40('0x21'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x320317,_0x18e89e,_0x4068b3){return getChanSpyPromise(_0x4d76d6,_0x320317)[_0x1e40('0x1c')](function(_0x44a46c){if(_0x44a46c&&_0x44a46c[_0x1e40('0x18')]){return _0x4d76d6[_0x1e40('0x22')]['bulkCreate'](_0x44a46c);}})[_0x1e40('0x1c')](function(){_0x4068b3();})[_0x1e40('0x1d')](function(_0x2e9339){_0x4068b3(_0x2e9339);});},'afterUpdate':function(_0x42e857,_0x360dc1,_0x42726a){return _0x4d76d6[_0x1e40('0x22')]['destroy']({'where':{'ChanSpyId':_0x42e857['id']}})[_0x1e40('0x1c')](function(){return getChanSpyPromise(_0x4d76d6,_0x42e857);})[_0x1e40('0x1c')](function(_0x6a37d2){if(_0x6a37d2&&_0x6a37d2['length']){return _0x4d76d6[_0x1e40('0x22')]['bulkCreate'](_0x6a37d2);}})[_0x1e40('0x1c')](function(){_0x42726a();})[_0x1e40('0x1d')](function(_0xf4fb11){_0x42726a(_0xf4fb11);});},'afterDestroy':function(_0xc9502d,_0x458c77,_0x2551eb){return _0x4d76d6[_0x1e40('0x22')]['destroy']({'where':{'ChanSpyId':_0xc9502d['id']}})[_0x1e40('0x1c')](function(){_0x2551eb();})['catch'](function(_0x1f39b4){_0x2551eb(_0x1f39b4);});}}});};
\ No newline at end of file