Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / interval / interval.rpc.js
index 8ceaf7a..1174e66 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf5c3=['raw','where','attributes','limit','include','map','model','Interval','ShowInterval','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','Interval,\x20%s,\x20%s','debug','Interval,\x20%s,\x20%s,\x20%s','request\x20sent','code','error','message','result','catch','GetInterval','findAll','options'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xf5c3,0x1ba));var _0x3f5c=function(_0x78ba87,_0xfea440){_0x78ba87=_0x78ba87-0x0;var _0x17239c=_0xf5c3[_0x78ba87];return _0x17239c;};'use strict';var _=require(_0x3f5c('0x0'));var util=require(_0x3f5c('0x1'));var moment=require(_0x3f5c('0x2'));var BPromise=require(_0x3f5c('0x3'));var rs=require(_0x3f5c('0x4'));var fs=require('fs');var Redis=require(_0x3f5c('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x3f5c('0x6'));var logger=require(_0x3f5c('0x7'))(_0x3f5c('0x8'));var config=require(_0x3f5c('0x9'));var jayson=require(_0x3f5c('0xa'));var client=jayson['client'][_0x3f5c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5513a5,_0x50be1f,_0x403c34){return new BPromise(function(_0xb755b3,_0x26852e){return client['request'](_0x5513a5,_0x403c34)[_0x3f5c('0xc')](function(_0x42c648){logger[_0x3f5c('0xd')](_0x3f5c('0xe'),_0x50be1f,'request\x20sent');logger[_0x3f5c('0xf')](_0x3f5c('0x10'),_0x50be1f,_0x3f5c('0x11'),JSON['stringify'](_0x42c648));if(_0x42c648['error']){if(_0x42c648['error'][_0x3f5c('0x12')]===0x1f4){logger['error'](_0x3f5c('0xe'),_0x50be1f,_0x42c648[_0x3f5c('0x13')][_0x3f5c('0x14')]);return _0x26852e(_0x42c648[_0x3f5c('0x13')][_0x3f5c('0x14')]);}logger[_0x3f5c('0x13')]('Interval,\x20%s,\x20%s',_0x50be1f,_0x42c648[_0x3f5c('0x13')][_0x3f5c('0x14')]);return _0xb755b3(_0x42c648[_0x3f5c('0x13')][_0x3f5c('0x14')]);}else{logger['info'](_0x3f5c('0xe'),_0x50be1f,_0x3f5c('0x11'));_0xb755b3(_0x42c648[_0x3f5c('0x15')][_0x3f5c('0x14')]);}})[_0x3f5c('0x16')](function(_0x5d5a65){logger[_0x3f5c('0x13')]('Interval,\x20%s,\x20%s',_0x50be1f,_0x5d5a65);_0x26852e(_0x5d5a65);});});}exports[_0x3f5c('0x17')]=function(_0x1548fe){var _0x216426=this;return new Promise(function(_0x44ea6c,_0x2416c5){return db['Interval'][_0x3f5c('0x18')]({'raw':_0x1548fe[_0x3f5c('0x19')]?_0x1548fe[_0x3f5c('0x19')][_0x3f5c('0x1a')]===undefined?!![]:![]:!![],'where':_0x1548fe[_0x3f5c('0x19')]?_0x1548fe['options'][_0x3f5c('0x1b')]||null:null,'attributes':_0x1548fe['options']?_0x1548fe[_0x3f5c('0x19')][_0x3f5c('0x1c')]||null:null,'limit':_0x1548fe['options']?_0x1548fe[_0x3f5c('0x19')][_0x3f5c('0x1d')]||null:null,'include':_0x1548fe[_0x3f5c('0x19')]?_0x1548fe[_0x3f5c('0x19')][_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0x1548fe[_0x3f5c('0x19')][_0x3f5c('0x1e')],function(_0x1309cf){return{'model':db[_0x1309cf[_0x3f5c('0x20')]],'as':_0x1309cf['as'],'attributes':_0x1309cf[_0x3f5c('0x1c')],'include':_0x1309cf[_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0x1309cf[_0x3f5c('0x1e')],function(_0xb277fa){return{'model':db[_0xb277fa[_0x3f5c('0x20')]],'as':_0xb277fa['as'],'attributes':_0xb277fa['attributes'],'include':_0xb277fa[_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0xb277fa['include'],function(_0x46de2f){return{'model':db[_0x46de2f[_0x3f5c('0x20')]],'as':_0x46de2f['as'],'attributes':_0x46de2f[_0x3f5c('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xcad079){logger['info'](_0x3f5c('0x17'),_0x1548fe);logger[_0x3f5c('0xf')]('GetInterval',_0x1548fe,JSON['stringify'](_0xcad079));_0x44ea6c(_0xcad079);})[_0x3f5c('0x16')](function(_0xe24ccb){logger[_0x3f5c('0x13')](_0x3f5c('0x17'),_0xe24ccb['message'],_0x1548fe);_0x2416c5(_0x216426[_0x3f5c('0x13')](0x1f4,_0xe24ccb[_0x3f5c('0x14')]));});});};exports['ShowInterval']=function(_0xf6046f){var _0x18795a=this;return new Promise(function(_0x5375c4,_0x1f1201){return db[_0x3f5c('0x21')]['find']({'raw':_0xf6046f['options']?_0xf6046f[_0x3f5c('0x19')][_0x3f5c('0x1a')]===undefined?!![]:![]:!![],'where':_0xf6046f[_0x3f5c('0x19')]?_0xf6046f[_0x3f5c('0x19')][_0x3f5c('0x1b')]||null:null,'attributes':_0xf6046f[_0x3f5c('0x19')]?_0xf6046f[_0x3f5c('0x19')][_0x3f5c('0x1c')]||null:null,'include':_0xf6046f['options']?_0xf6046f[_0x3f5c('0x19')][_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0xf6046f['options'][_0x3f5c('0x1e')],function(_0x15ca58){return{'model':db[_0x15ca58['model']],'as':_0x15ca58['as'],'attributes':_0x15ca58[_0x3f5c('0x1c')],'include':_0x15ca58[_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0x15ca58[_0x3f5c('0x1e')],function(_0x30410a){return{'model':db[_0x30410a[_0x3f5c('0x20')]],'as':_0x30410a['as'],'attributes':_0x30410a['attributes'],'include':_0x30410a[_0x3f5c('0x1e')]?_[_0x3f5c('0x1f')](_0x30410a['include'],function(_0x8989c6){return{'model':db[_0x8989c6[_0x3f5c('0x20')]],'as':_0x8989c6['as'],'attributes':_0x8989c6[_0x3f5c('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x3f5c('0xc')](function(_0x41974a){logger[_0x3f5c('0xd')]('ShowInterval',_0xf6046f);logger[_0x3f5c('0xf')](_0x3f5c('0x22'),_0xf6046f,JSON[_0x3f5c('0x23')](_0x41974a));_0x5375c4(_0x41974a);})[_0x3f5c('0x16')](function(_0x28f1f2){logger[_0x3f5c('0x13')](_0x3f5c('0x22'),_0x28f1f2['message'],_0xf6046f);_0x1f1201(_0x18795a[_0x3f5c('0x13')](0x1f4,_0x28f1f2[_0x3f5c('0x14')]));});});};
\ No newline at end of file
+var _0x9354=['resolve','lodash','util','../../mysqldb','rpc','Interval','options','where','attributes','map','include','model','then','info','debug','stringify','catch','error','message','raw','ShowInterval','ifTime','reduce','format','IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)','name','findById','IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)','IntervalIftime','isArray','intervals','string','timezone','join','IntervalIftime:\x20timezone\x20=\x20%s','Iftime'];(function(_0x58bcd0,_0x17d4aa){var _0x1a7310=function(_0x4f7003){while(--_0x4f7003){_0x58bcd0['push'](_0x58bcd0['shift']());}};_0x1a7310(++_0x17d4aa);}(_0x9354,0x145));var _0x4935=function(_0x4186fa,_0x26a01c){_0x4186fa=_0x4186fa-0x0;var _0x136990=_0x9354[_0x4186fa];return _0x136990;};'use strict';var _=require(_0x4935('0x0'));var util=require(_0x4935('0x1'));var db=require(_0x4935('0x2'))['db'];var iftime=require('../../utils/iftime')['iftime'];var logger=require('../../config/logger')(_0x4935('0x3'));exports['GetInterval']=function(_0x1861e6){var _0x3b3a54=this;return new Promise(function(_0xcc4f42,_0x4191a1){return db[_0x4935('0x4')]['findAll']({'raw':_0x1861e6[_0x4935('0x5')]?_0x1861e6[_0x4935('0x5')]['raw']===undefined?!![]:![]:!![],'where':_0x1861e6[_0x4935('0x5')]?_0x1861e6[_0x4935('0x5')][_0x4935('0x6')]||null:null,'attributes':_0x1861e6[_0x4935('0x5')]?_0x1861e6[_0x4935('0x5')][_0x4935('0x7')]||null:null,'limit':_0x1861e6[_0x4935('0x5')]?_0x1861e6[_0x4935('0x5')]['limit']||null:null,'include':_0x1861e6[_0x4935('0x5')]?_0x1861e6[_0x4935('0x5')]['include']?_[_0x4935('0x8')](_0x1861e6[_0x4935('0x5')][_0x4935('0x9')],function(_0x58b6f0){return{'model':db[_0x58b6f0[_0x4935('0xa')]],'as':_0x58b6f0['as'],'attributes':_0x58b6f0[_0x4935('0x7')],'include':_0x58b6f0[_0x4935('0x9')]?_[_0x4935('0x8')](_0x58b6f0[_0x4935('0x9')],function(_0x23e204){return{'model':db[_0x23e204[_0x4935('0xa')]],'as':_0x23e204['as'],'attributes':_0x23e204[_0x4935('0x7')],'include':_0x23e204[_0x4935('0x9')]?_[_0x4935('0x8')](_0x23e204[_0x4935('0x9')],function(_0x406978){return{'model':db[_0x406978[_0x4935('0xa')]],'as':_0x406978['as'],'attributes':_0x406978[_0x4935('0x7')]};}):[]};}):[]};}):[]:[]})[_0x4935('0xb')](function(_0xf9f668){logger[_0x4935('0xc')]('GetInterval',_0x1861e6);logger[_0x4935('0xd')]('GetInterval',_0x1861e6,JSON[_0x4935('0xe')](_0xf9f668));_0xcc4f42(_0xf9f668);})[_0x4935('0xf')](function(_0x381f9e){logger[_0x4935('0x10')]('GetInterval',_0x381f9e[_0x4935('0x11')],_0x1861e6);_0x4191a1(_0x3b3a54[_0x4935('0x10')](0x1f4,_0x381f9e[_0x4935('0x11')]));});});};exports['ShowInterval']=function(_0x4f19a0){var _0x4f3f20=this;return new Promise(function(_0x28c8c3,_0x951c3c){return db[_0x4935('0x4')]['find']({'raw':_0x4f19a0[_0x4935('0x5')]?_0x4f19a0['options'][_0x4935('0x12')]===undefined?!![]:![]:!![],'where':_0x4f19a0['options']?_0x4f19a0[_0x4935('0x5')]['where']||null:null,'attributes':_0x4f19a0[_0x4935('0x5')]?_0x4f19a0[_0x4935('0x5')][_0x4935('0x7')]||null:null,'include':_0x4f19a0[_0x4935('0x5')]?_0x4f19a0[_0x4935('0x5')]['include']?_[_0x4935('0x8')](_0x4f19a0['options'][_0x4935('0x9')],function(_0x274b46){return{'model':db[_0x274b46[_0x4935('0xa')]],'as':_0x274b46['as'],'attributes':_0x274b46['attributes'],'include':_0x274b46[_0x4935('0x9')]?_[_0x4935('0x8')](_0x274b46[_0x4935('0x9')],function(_0x5f4b4c){return{'model':db[_0x5f4b4c[_0x4935('0xa')]],'as':_0x5f4b4c['as'],'attributes':_0x5f4b4c[_0x4935('0x7')],'include':_0x5f4b4c[_0x4935('0x9')]?_['map'](_0x5f4b4c[_0x4935('0x9')],function(_0x2a0e85){return{'model':db[_0x2a0e85['model']],'as':_0x2a0e85['as'],'attributes':_0x2a0e85['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4ed777){logger[_0x4935('0xc')](_0x4935('0x13'),_0x4f19a0);logger[_0x4935('0xd')](_0x4935('0x13'),_0x4f19a0,JSON['stringify'](_0x4ed777));_0x28c8c3(_0x4ed777);})['catch'](function(_0x34ea29){logger[_0x4935('0x10')](_0x4935('0x13'),_0x34ea29[_0x4935('0x11')],_0x4f19a0);_0x951c3c(_0x4f3f20[_0x4935('0x10')](0x1f4,_0x34ea29[_0x4935('0x11')]));});});};function checkArrayOfIntervals(_0x3a04eb,_0x1cb8aa){var _0x57e505=[];return db['Interval']['findAll']({'where':{'id':_0x3a04eb}})[_0x4935('0xb')](function(_0x129d4d){_0x57e505=_0x129d4d;return Promise['all'](_0x57e505[_0x4935('0x8')](function(_0x57956e){return _0x57956e[_0x4935('0x14')](_0x1cb8aa);}));})[_0x4935('0xb')](function(_0x216384){var _0x3a166c=_0x216384[_0x4935('0x15')](function(_0xffc78,_0x459ffa){return _0xffc78||_0x459ffa;},![]);logger['info'](util[_0x4935('0x16')](_0x4935('0x17'),_0x57e505[_0x4935('0x8')](function(_0x399056){return _0x399056[_0x4935('0x18')];})['join'](',\x20'),_0x57e505[_0x4935('0x8')](function(_0xff08d7){return _0xff08d7['id'];})['join'](',\x20')));return _0x3a166c;});}function checkSingleInterval(_0x579baf,_0x16ef02){return db[_0x4935('0x4')][_0x4935('0x19')](_0x579baf)[_0x4935('0xb')](function(_0x9f6471){if(_0x9f6471){logger[_0x4935('0xc')](util[_0x4935('0x16')](_0x4935('0x1a'),_0x9f6471['name'],_0x9f6471['id']));return _0x9f6471['ifTime'](_0x16ef02);}});}exports[_0x4935('0x1b')]=function(_0xe9799f){var _0x3baab0=_0xe9799f['intervalIds'];var _0x386f70=Array[_0x4935('0x1c')](_0xe9799f['intervals'])?_0xe9799f[_0x4935('0x1d')]:typeof _0xe9799f[_0x4935('0x1d')]===_0x4935('0x1e')?[_0xe9799f['intervals']]:[];var _0x19e5c9=_0xe9799f[_0x4935('0x1f')]||undefined;var _0x4f5974=![];if(_0x386f70['length']){logger[_0x4935('0xc')](util[_0x4935('0x16')]('IntervalIftime:\x20interval\x20strings\x20=\x20%s',_0x386f70[_0x4935('0x20')](';\x20')));}if(_0x19e5c9){logger[_0x4935('0xc')](util['format'](_0x4935('0x21'),_0x19e5c9));}logger['debug'](_0x4935('0x22'),_0x4f5974);logger['silly'](_0x4935('0x1b'),_0xe9799f);return Promise[_0x4935('0x23')]()[_0x4935('0xb')](function(){if(Array[_0x4935('0x1c')](_0x3baab0)){return checkArrayOfIntervals(_0x3baab0,_0x19e5c9);}else if(_0x3baab0){return checkSingleInterval(_0x3baab0,_0x19e5c9);}})['then'](function(_0x481982){var _0xb74589=_0x386f70[_0x4935('0x15')](function(_0x3c2468,_0xa53e8f){return _0x3c2468||iftime(_0xa53e8f,_0x19e5c9);},![]);_0x4f5974=_0x481982||_0xb74589;return _0x4f5974;})[_0x4935('0xf')](function(_0x1e0294){logger[_0x4935('0x10')](_0x4935('0x1b'),_0xe9799f,_0x1e0294);throw this['error'](0x1f4,_0x1e0294[_0x4935('0x11')]);});};
\ No newline at end of file