Built motion from commit 1cfc41f6.|2.5.41
[motion2.git] / server / api / voiceChanSpy / voiceChanSpy.model.js
index 14253d5..578346c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x34f7=['bulkCreate','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','from-sip','format','prefix','push','merge','CDR(type)=%s','MixMonitor','recordingFormat','auth','password','ChanSpy','SIP/%s,%s','name','options','join','StopMixMonitor','length','concat','internal','User','agent','then','catch','exports','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x34f7,0x11a));var _0x734f=function(_0x2fcd42,_0x54387c){_0x2fcd42=_0x2fcd42-0x0;var _0x2f428c=_0x34f7[_0x2fcd42];return _0x2f428c;};'use strict';var _=require(_0x734f('0x0'));var util=require(_0x734f('0x1'));var BPromise=require(_0x734f('0x2'));var attributes=require(_0x734f('0x3'));var getUserApplications=function(_0x2e3e97,_0xf9921e,_0x2e6432){var _0x25d42a=0x1;var _0x35e6ec=[];var _0x4cf8a9={'context':_0xf9921e['context']||_0x734f('0x4'),'exten':util[_0x734f('0x5')]('%s%s',_0x2e3e97[_0x734f('0x6')],_0x2e6432),'type':'system','isApp':![],'ChanSpyId':_0x2e3e97['id'],'UserId':_0xf9921e['id']};_0x35e6ec[_0x734f('0x7')](_[_0x734f('0x8')]({'app':'Set','appdata':util[_0x734f('0x5')](_0x734f('0x9'),'chanspy'),'priority':_0x25d42a++},_0x4cf8a9));if(_0x2e3e97['record']){_0x35e6ec[_0x734f('0x7')](_[_0x734f('0x8')]({'app':_0x734f('0xa'),'appdata':util['format']('${UNIQUEID}.%s,a',_0x2e3e97[_0x734f('0xb')]),'priority':_0x25d42a++},_0x4cf8a9));}if(_0x2e3e97[_0x734f('0xc')]){_0x35e6ec[_0x734f('0x7')](_[_0x734f('0x8')]({'app':'Authenticate','appdata':_0x2e3e97[_0x734f('0xd')],'priority':_0x25d42a++},_0x4cf8a9));}_0x35e6ec['push'](_[_0x734f('0x8')]({'app':_0x734f('0xe'),'appdata':util[_0x734f('0x5')](_0x734f('0xf'),_0xf9921e[_0x734f('0x10')],_0x2e3e97[_0x734f('0x11')]?_0x2e3e97['options'][_0x734f('0x12')](''):''),'priority':_0x25d42a++},_0x4cf8a9));if(_0x2e3e97['record']){_0x35e6ec[_0x734f('0x7')](_['merge']({'app':_0x734f('0x13'),'priority':_0x25d42a++},_0x4cf8a9));}return _0x35e6ec;};var getChanSpyApplications=function(_0x4e5e51,_0x4e3bbb){var _0x50e28e=[];for(var _0x227793=0x0,_0x17385d=0x1;_0x227793<_0x4e3bbb[_0x734f('0x14')];_0x227793++,_0x17385d=0x1){_0x50e28e=_0x50e28e[_0x734f('0x15')](getUserApplications(_0x4e5e51,_0x4e3bbb[_0x227793],_0x4e3bbb[_0x227793][_0x734f('0x16')]));if(_0x4e3bbb[_0x227793][_0x734f('0x16')]!=_0x4e3bbb[_0x227793][_0x734f('0x10')]){_0x50e28e=_0x50e28e[_0x734f('0x15')](getUserApplications(_0x4e5e51,_0x4e3bbb[_0x227793],_0x4e3bbb[_0x227793][_0x734f('0x10')]));}}return _0x50e28e;};var getChanSpyPromise=function(_0x2d46b1,_0x2f20d5){return new BPromise(function(_0x53925b,_0x96507){return _0x2d46b1[_0x734f('0x17')]['findAll']({'attributes':['id','name',_0x734f('0x16')],'where':{'role':_0x734f('0x18'),'chanspy':!![]},'raw':!![]})[_0x734f('0x19')](function(_0x3d64a8){if(_0x3d64a8){return _0x53925b(getChanSpyApplications(_0x2f20d5,_0x3d64a8));}return _0x53925b([]);})[_0x734f('0x1a')](function(_0x457881){_0x96507(_0x457881);});});};module[_0x734f('0x1b')]=function(_0x173bfd,_0xb6278f){var _0x342ee7=_0x173bfd[_0x734f('0x1c')];return _0x173bfd[_0x734f('0x1d')](_0x734f('0x1e'),attributes,{'tableName':_0x734f('0x1f'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x4702c4,_0x1c3d00,_0xe3a679){return getChanSpyPromise(_0x342ee7,_0x4702c4)['then'](function(_0x1046bb){if(_0x1046bb&&_0x1046bb[_0x734f('0x14')]){return _0x342ee7['VoiceExtension']['bulkCreate'](_0x1046bb);}})['then'](function(){_0xe3a679();})[_0x734f('0x1a')](function(_0x25356e){_0xe3a679(_0x25356e);});},'afterUpdate':function(_0x2d0be5,_0xbc6a21,_0x25effc){return _0x342ee7[_0x734f('0x20')]['destroy']({'where':{'ChanSpyId':_0x2d0be5['id']}})[_0x734f('0x19')](function(){return getChanSpyPromise(_0x342ee7,_0x2d0be5);})[_0x734f('0x19')](function(_0x2783cb){if(_0x2783cb&&_0x2783cb[_0x734f('0x14')]){return _0x342ee7[_0x734f('0x20')][_0x734f('0x21')](_0x2783cb);}})[_0x734f('0x19')](function(){_0x25effc();})[_0x734f('0x1a')](function(_0x53256e){_0x25effc(_0x53256e);});},'afterDestroy':function(_0x2b17b8,_0xad82f0,_0x362fa7){return _0x342ee7[_0x734f('0x20')][_0x734f('0x22')]({'where':{'ChanSpyId':_0x2b17b8['id']}})[_0x734f('0x19')](function(){_0x362fa7();})[_0x734f('0x1a')](function(_0x56987d){_0x362fa7(_0x56987d);});}}});};
\ No newline at end of file
+var _0x940f=['recordingFormat','auth','Authenticate','password','ChanSpy','SIP/%s,%s','name','join','record','length','concat','internal','User','findAll','agent','then','exports','models','define','VoiceChanSpy','voice_chanspy','VoiceExtension','catch','destroy','lodash','util','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','system','merge','Set','CDR(type)=%s','chanspy','push','MixMonitor','${UNIQUEID}.%s,a'];(function(_0x57834a,_0x5c10f6){var _0x4b2136=function(_0x14a082){while(--_0x14a082){_0x57834a['push'](_0x57834a['shift']());}};_0x4b2136(++_0x5c10f6);}(_0x940f,0x158));var _0xf940=function(_0x39749c,_0x55e728){_0x39749c=_0x39749c-0x0;var _0x4784f0=_0x940f[_0x39749c];return _0x4784f0;};'use strict';var _=require(_0xf940('0x0'));var util=require(_0xf940('0x1'));var BPromise=require(_0xf940('0x2'));var attributes=require(_0xf940('0x3'));var getUserApplications=function(_0x33d47b,_0x2d00b3,_0x57fbd3){var _0x162023=0x1;var _0x23f80e=[];var _0x2588d3={'context':_0x2d00b3[_0xf940('0x4')]||_0xf940('0x5'),'exten':util[_0xf940('0x6')](_0xf940('0x7'),_0x33d47b['prefix'],_0x57fbd3),'type':_0xf940('0x8'),'isApp':![],'ChanSpyId':_0x33d47b['id'],'UserId':_0x2d00b3['id']};_0x23f80e['push'](_[_0xf940('0x9')]({'app':_0xf940('0xa'),'appdata':util['format'](_0xf940('0xb'),_0xf940('0xc')),'priority':_0x162023++},_0x2588d3));if(_0x33d47b['record']){_0x23f80e[_0xf940('0xd')](_[_0xf940('0x9')]({'app':_0xf940('0xe'),'appdata':util[_0xf940('0x6')](_0xf940('0xf'),_0x33d47b[_0xf940('0x10')]),'priority':_0x162023++},_0x2588d3));}if(_0x33d47b[_0xf940('0x11')]){_0x23f80e[_0xf940('0xd')](_[_0xf940('0x9')]({'app':_0xf940('0x12'),'appdata':_0x33d47b[_0xf940('0x13')],'priority':_0x162023++},_0x2588d3));}_0x23f80e[_0xf940('0xd')](_[_0xf940('0x9')]({'app':_0xf940('0x14'),'appdata':util['format'](_0xf940('0x15'),_0x2d00b3[_0xf940('0x16')],_0x33d47b['options']?_0x33d47b['options'][_0xf940('0x17')](''):''),'priority':_0x162023++},_0x2588d3));if(_0x33d47b[_0xf940('0x18')]){_0x23f80e['push'](_['merge']({'app':'StopMixMonitor','priority':_0x162023++},_0x2588d3));}return _0x23f80e;};var getChanSpyApplications=function(_0x54d811,_0x558836){var _0x3a22f0=[];for(var _0x1c31f1=0x0,_0x16cf42=0x1;_0x1c31f1<_0x558836[_0xf940('0x19')];_0x1c31f1++,_0x16cf42=0x1){_0x3a22f0=_0x3a22f0[_0xf940('0x1a')](getUserApplications(_0x54d811,_0x558836[_0x1c31f1],_0x558836[_0x1c31f1][_0xf940('0x1b')]));if(_0x558836[_0x1c31f1][_0xf940('0x1b')]!=_0x558836[_0x1c31f1]['name']){_0x3a22f0=_0x3a22f0[_0xf940('0x1a')](getUserApplications(_0x54d811,_0x558836[_0x1c31f1],_0x558836[_0x1c31f1]['name']));}}return _0x3a22f0;};var getChanSpyPromise=function(_0xc02faf,_0x4a3f29){return new BPromise(function(_0x179b43,_0x4fb9d1){return _0xc02faf[_0xf940('0x1c')][_0xf940('0x1d')]({'attributes':['id',_0xf940('0x16'),_0xf940('0x1b')],'where':{'role':_0xf940('0x1e'),'chanspy':!![]},'raw':!![]})[_0xf940('0x1f')](function(_0x424d02){if(_0x424d02){return _0x179b43(getChanSpyApplications(_0x4a3f29,_0x424d02));}return _0x179b43([]);})['catch'](function(_0x1a4615){_0x4fb9d1(_0x1a4615);});});};module[_0xf940('0x20')]=function(_0x98943c,_0x39af07){var _0x42eadb=_0x98943c[_0xf940('0x21')];return _0x98943c[_0xf940('0x22')](_0xf940('0x23'),attributes,{'tableName':_0xf940('0x24'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x11a174,_0x2791f2,_0x3ac156){return getChanSpyPromise(_0x42eadb,_0x11a174)['then'](function(_0x3c9422){if(_0x3c9422&&_0x3c9422[_0xf940('0x19')]){return _0x42eadb[_0xf940('0x25')]['bulkCreate'](_0x3c9422);}})['then'](function(){_0x3ac156();})[_0xf940('0x26')](function(_0x4272e5){_0x3ac156(_0x4272e5);});},'afterUpdate':function(_0xed5b5b,_0x4a2e05,_0x278915){return _0x42eadb[_0xf940('0x25')][_0xf940('0x27')]({'where':{'ChanSpyId':_0xed5b5b['id']}})['then'](function(){return getChanSpyPromise(_0x42eadb,_0xed5b5b);})[_0xf940('0x1f')](function(_0x30d9d4){if(_0x30d9d4&&_0x30d9d4[_0xf940('0x19')]){return _0x42eadb[_0xf940('0x25')]['bulkCreate'](_0x30d9d4);}})[_0xf940('0x1f')](function(){_0x278915();})[_0xf940('0x26')](function(_0x3f32f3){_0x278915(_0x3f32f3);});},'afterDestroy':function(_0x407619,_0xc505f1,_0x5ebb39){return _0x42eadb[_0xf940('0x25')][_0xf940('0x27')]({'where':{'ChanSpyId':_0x407619['id']}})[_0xf940('0x1f')](function(){_0x5ebb39();})[_0xf940('0x26')](function(_0x30a4b4){_0x5ebb39(_0x30a4b4);});}}});};
\ No newline at end of file