Built motion from commit cb845558.|2.6.34
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index a4094dd..a0b252a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcc57=['bluebird','from-sip','format','%s%s','prefix','system','push','CDR(type)=%s','chanspy','record','merge','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','auth','Authenticate','password','ChanSpy','name','options','join','StopMixMonitor','length','concat','internal','User','agent','catch','VoiceChanSpy','then','VoiceExtension','bulkCreate','destroy','lodash','util'];(function(_0x3ee55a,_0x19aeea){var _0x581800=function(_0x636cb7){while(--_0x636cb7){_0x3ee55a['push'](_0x3ee55a['shift']());}};_0x581800(++_0x19aeea);}(_0xcc57,0x8a));var _0x7cc5=function(_0x201b53,_0x2536f9){_0x201b53=_0x201b53-0x0;var _0x3b2e6b=_0xcc57[_0x201b53];return _0x3b2e6b;};'use strict';var _=require(_0x7cc5('0x0'));var util=require(_0x7cc5('0x1'));var BPromise=require(_0x7cc5('0x2'));var attributes=require('./voiceChanSpy.attributes');var getUserApplications=function(_0x3da8f6,_0x34430f,_0x2c5aed){var _0x133075=0x1;var _0x3948ef=[];var _0x39c40f={'context':_0x34430f['context']||_0x7cc5('0x3'),'exten':util[_0x7cc5('0x4')](_0x7cc5('0x5'),_0x3da8f6[_0x7cc5('0x6')],_0x2c5aed),'type':_0x7cc5('0x7'),'isApp':![],'ChanSpyId':_0x3da8f6['id'],'UserId':_0x34430f['id']};_0x3948ef[_0x7cc5('0x8')](_['merge']({'app':'Set','appdata':util['format'](_0x7cc5('0x9'),_0x7cc5('0xa')),'priority':_0x133075++},_0x39c40f));if(_0x3da8f6[_0x7cc5('0xb')]){_0x3948ef[_0x7cc5('0x8')](_[_0x7cc5('0xc')]({'app':_0x7cc5('0xd'),'appdata':util[_0x7cc5('0x4')](_0x7cc5('0xe'),_0x3da8f6[_0x7cc5('0xf')]),'priority':_0x133075++},_0x39c40f));}if(_0x3da8f6[_0x7cc5('0x10')]){_0x3948ef[_0x7cc5('0x8')](_[_0x7cc5('0xc')]({'app':_0x7cc5('0x11'),'appdata':_0x3da8f6[_0x7cc5('0x12')],'priority':_0x133075++},_0x39c40f));}_0x3948ef[_0x7cc5('0x8')](_[_0x7cc5('0xc')]({'app':_0x7cc5('0x13'),'appdata':util[_0x7cc5('0x4')]('SIP/%s,%s',_0x34430f[_0x7cc5('0x14')],_0x3da8f6['options']?_0x3da8f6[_0x7cc5('0x15')][_0x7cc5('0x16')](''):''),'priority':_0x133075++},_0x39c40f));if(_0x3da8f6[_0x7cc5('0xb')]){_0x3948ef[_0x7cc5('0x8')](_[_0x7cc5('0xc')]({'app':_0x7cc5('0x17'),'priority':_0x133075++},_0x39c40f));}return _0x3948ef;};var getChanSpyApplications=function(_0x2001c7,_0x576f40){var _0x5e7c45=[];for(var _0x5dcd85=0x0,_0x4256e9=0x1;_0x5dcd85<_0x576f40[_0x7cc5('0x18')];_0x5dcd85++,_0x4256e9=0x1){_0x5e7c45=_0x5e7c45[_0x7cc5('0x19')](getUserApplications(_0x2001c7,_0x576f40[_0x5dcd85],_0x576f40[_0x5dcd85][_0x7cc5('0x1a')]));if(_0x576f40[_0x5dcd85][_0x7cc5('0x1a')]!=_0x576f40[_0x5dcd85][_0x7cc5('0x14')]){_0x5e7c45=_0x5e7c45[_0x7cc5('0x19')](getUserApplications(_0x2001c7,_0x576f40[_0x5dcd85],_0x576f40[_0x5dcd85][_0x7cc5('0x14')]));}}return _0x5e7c45;};var getChanSpyPromise=function(_0x3d9fba,_0x205318){return new BPromise(function(_0x362606,_0x3be72c){return _0x3d9fba[_0x7cc5('0x1b')]['findAll']({'attributes':['id',_0x7cc5('0x14'),_0x7cc5('0x1a')],'where':{'role':_0x7cc5('0x1c'),'chanspy':!![]},'raw':!![]})['then'](function(_0x923798){if(_0x923798){return _0x362606(getChanSpyApplications(_0x205318,_0x923798));}return _0x362606([]);})[_0x7cc5('0x1d')](function(_0x2b541c){_0x3be72c(_0x2b541c);});});};module['exports']=function(_0x3d6d74,_0x202326){var _0x564581=_0x3d6d74['models'];return _0x3d6d74['define'](_0x7cc5('0x1e'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1d3bf1,_0x391072,_0x3e7e17){return getChanSpyPromise(_0x564581,_0x1d3bf1)[_0x7cc5('0x1f')](function(_0x3f4041){if(_0x3f4041&&_0x3f4041[_0x7cc5('0x18')]){return _0x564581['VoiceExtension']['bulkCreate'](_0x3f4041);}})[_0x7cc5('0x1f')](function(){_0x3e7e17();})[_0x7cc5('0x1d')](function(_0x4eb4d1){_0x3e7e17(_0x4eb4d1);});},'afterUpdate':function(_0x1d12ce,_0x175b9e,_0x1e0b91){return _0x564581[_0x7cc5('0x20')]['destroy']({'where':{'ChanSpyId':_0x1d12ce['id']}})[_0x7cc5('0x1f')](function(){return getChanSpyPromise(_0x564581,_0x1d12ce);})[_0x7cc5('0x1f')](function(_0x966ad5){if(_0x966ad5&&_0x966ad5[_0x7cc5('0x18')]){return _0x564581[_0x7cc5('0x20')][_0x7cc5('0x21')](_0x966ad5);}})['then'](function(){_0x1e0b91();})[_0x7cc5('0x1d')](function(_0xd95733){_0x1e0b91(_0xd95733);});},'afterDestroy':function(_0x21dece,_0x202c2c,_0x3e11fb){return _0x564581[_0x7cc5('0x20')][_0x7cc5('0x22')]({'where':{'ChanSpyId':_0x21dece['id']}})['then'](function(){_0x3e11fb();})['catch'](function(_0x38a7bb){_0x3e11fb(_0x38a7bb);});}}});};
\ No newline at end of file
+var _0x30f9=['destroy','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','prefix','push','merge','Set','CDR(type)=%s','chanspy','record','MixMonitor','${UNIQUEID}.%s,a','recordingFormat','Authenticate','password','ChanSpy','name','options','join','StopMixMonitor','length','concat','internal','User','findAll','then','catch','exports','models','VoiceChanSpy','bulkCreate','VoiceExtension'];(function(_0x765b92,_0xe062ac){var _0x55ac4c=function(_0x97c044){while(--_0x97c044){_0x765b92['push'](_0x765b92['shift']());}};_0x55ac4c(++_0xe062ac);}(_0x30f9,0x129));var _0x930f=function(_0x929c7e,_0x38c4cc){_0x929c7e=_0x929c7e-0x0;var _0x5de099=_0x30f9[_0x929c7e];return _0x5de099;};'use strict';var _=require('lodash');var util=require(_0x930f('0x0'));var BPromise=require(_0x930f('0x1'));var attributes=require(_0x930f('0x2'));var getUserApplications=function(_0x2f11ef,_0x13d7d2,_0x1dc68c){var _0x43b04a=0x1;var _0x52431e=[];var _0x2d1d82={'context':_0x13d7d2[_0x930f('0x3')]||_0x930f('0x4'),'exten':util[_0x930f('0x5')](_0x930f('0x6'),_0x2f11ef[_0x930f('0x7')],_0x1dc68c),'type':'system','isApp':![],'ChanSpyId':_0x2f11ef['id'],'UserId':_0x13d7d2['id']};_0x52431e[_0x930f('0x8')](_[_0x930f('0x9')]({'app':_0x930f('0xa'),'appdata':util[_0x930f('0x5')](_0x930f('0xb'),_0x930f('0xc')),'priority':_0x43b04a++},_0x2d1d82));if(_0x2f11ef[_0x930f('0xd')]){_0x52431e['push'](_[_0x930f('0x9')]({'app':_0x930f('0xe'),'appdata':util['format'](_0x930f('0xf'),_0x2f11ef[_0x930f('0x10')]),'priority':_0x43b04a++},_0x2d1d82));}if(_0x2f11ef['auth']){_0x52431e[_0x930f('0x8')](_[_0x930f('0x9')]({'app':_0x930f('0x11'),'appdata':_0x2f11ef[_0x930f('0x12')],'priority':_0x43b04a++},_0x2d1d82));}_0x52431e[_0x930f('0x8')](_[_0x930f('0x9')]({'app':_0x930f('0x13'),'appdata':util['format']('SIP/%s,%s',_0x13d7d2[_0x930f('0x14')],_0x2f11ef[_0x930f('0x15')]?_0x2f11ef[_0x930f('0x15')][_0x930f('0x16')](''):''),'priority':_0x43b04a++},_0x2d1d82));if(_0x2f11ef[_0x930f('0xd')]){_0x52431e[_0x930f('0x8')](_['merge']({'app':_0x930f('0x17'),'priority':_0x43b04a++},_0x2d1d82));}return _0x52431e;};var getChanSpyApplications=function(_0x564dff,_0x14aae5){var _0x2c03c4=[];for(var _0x3f0a8b=0x0,_0x1927f2=0x1;_0x3f0a8b<_0x14aae5[_0x930f('0x18')];_0x3f0a8b++,_0x1927f2=0x1){_0x2c03c4=_0x2c03c4[_0x930f('0x19')](getUserApplications(_0x564dff,_0x14aae5[_0x3f0a8b],_0x14aae5[_0x3f0a8b][_0x930f('0x1a')]));if(_0x14aae5[_0x3f0a8b][_0x930f('0x1a')]!=_0x14aae5[_0x3f0a8b]['name']){_0x2c03c4=_0x2c03c4['concat'](getUserApplications(_0x564dff,_0x14aae5[_0x3f0a8b],_0x14aae5[_0x3f0a8b][_0x930f('0x14')]));}}return _0x2c03c4;};var getChanSpyPromise=function(_0x4bcd93,_0x393e3e){return new BPromise(function(_0x19d4c9,_0x1eb71c){return _0x4bcd93[_0x930f('0x1b')][_0x930f('0x1c')]({'attributes':['id',_0x930f('0x14'),'internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x930f('0x1d')](function(_0x3b3ed5){if(_0x3b3ed5){return _0x19d4c9(getChanSpyApplications(_0x393e3e,_0x3b3ed5));}return _0x19d4c9([]);})[_0x930f('0x1e')](function(_0x350ecd){_0x1eb71c(_0x350ecd);});});};module[_0x930f('0x1f')]=function(_0x13f4d5,_0x2cfc0b){var _0x181da2=_0x13f4d5[_0x930f('0x20')];return _0x13f4d5['define'](_0x930f('0x21'),attributes,{'tableName':'voice_chanspy','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0xf6743a,_0xac9dc2,_0x5854d8){return getChanSpyPromise(_0x181da2,_0xf6743a)[_0x930f('0x1d')](function(_0x55f031){if(_0x55f031&&_0x55f031[_0x930f('0x18')]){return _0x181da2['VoiceExtension'][_0x930f('0x22')](_0x55f031);}})[_0x930f('0x1d')](function(){_0x5854d8();})['catch'](function(_0x4d77f1){_0x5854d8(_0x4d77f1);});},'afterUpdate':function(_0x429072,_0x5b483f,_0x2b239c){return _0x181da2[_0x930f('0x23')][_0x930f('0x24')]({'where':{'ChanSpyId':_0x429072['id']}})[_0x930f('0x1d')](function(){return getChanSpyPromise(_0x181da2,_0x429072);})['then'](function(_0xaf11ec){if(_0xaf11ec&&_0xaf11ec[_0x930f('0x18')]){return _0x181da2[_0x930f('0x23')]['bulkCreate'](_0xaf11ec);}})['then'](function(){_0x2b239c();})['catch'](function(_0x20e9f4){_0x2b239c(_0x20e9f4);});},'afterDestroy':function(_0x4e304b,_0x3a3159,_0x2d9e9d){return _0x181da2[_0x930f('0x23')][_0x930f('0x24')]({'where':{'ChanSpyId':_0x4e304b['id']}})['then'](function(){_0x2d9e9d();})[_0x930f('0x1e')](function(_0x4f093e){_0x2d9e9d(_0x4f093e);});}}});};
\ No newline at end of file