Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / interval / interval.rpc.js
index de9e266..9f7791c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7013=['include','map','model','attributes','then','GetInterval','debug','stringify','catch','error','message','ShowInterval','Interval','find','info','all','ifTime','reduce','IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)','name','join','findById','format','IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)','IntervalIftime','intervalIds','isArray','intervals','string','timezone','length','IntervalIftime:\x20interval\x20strings\x20=\x20%s','Iftime','silly','lodash','util','../../mysqldb','iftime','../../config/logger','findAll','options','raw','where','limit'];(function(_0xf35bc1,_0x510803){var _0xa6b162=function(_0x1e5cc8){while(--_0x1e5cc8){_0xf35bc1['push'](_0xf35bc1['shift']());}};_0xa6b162(++_0x510803);}(_0x7013,0x1da));var _0x3701=function(_0x1f9b79,_0x6c46d3){_0x1f9b79=_0x1f9b79-0x0;var _0x38454d=_0x7013[_0x1f9b79];return _0x38454d;};'use strict';var _=require(_0x3701('0x0'));var util=require(_0x3701('0x1'));var db=require(_0x3701('0x2'))['db'];var iftime=require('../../utils/iftime')[_0x3701('0x3')];var logger=require(_0x3701('0x4'))('rpc');exports['GetInterval']=function(_0x126900){var _0x3d1f31=this;return new Promise(function(_0x55c999,_0x533303){return db['Interval'][_0x3701('0x5')]({'raw':_0x126900[_0x3701('0x6')]?_0x126900[_0x3701('0x6')][_0x3701('0x7')]===undefined?!![]:![]:!![],'where':_0x126900[_0x3701('0x6')]?_0x126900[_0x3701('0x6')][_0x3701('0x8')]||null:null,'attributes':_0x126900[_0x3701('0x6')]?_0x126900[_0x3701('0x6')]['attributes']||null:null,'limit':_0x126900[_0x3701('0x6')]?_0x126900[_0x3701('0x6')][_0x3701('0x9')]||null:null,'include':_0x126900[_0x3701('0x6')]?_0x126900[_0x3701('0x6')][_0x3701('0xa')]?_[_0x3701('0xb')](_0x126900[_0x3701('0x6')]['include'],function(_0x47d1cf){return{'model':db[_0x47d1cf[_0x3701('0xc')]],'as':_0x47d1cf['as'],'attributes':_0x47d1cf[_0x3701('0xd')],'include':_0x47d1cf[_0x3701('0xa')]?_[_0x3701('0xb')](_0x47d1cf[_0x3701('0xa')],function(_0x6fc473){return{'model':db[_0x6fc473['model']],'as':_0x6fc473['as'],'attributes':_0x6fc473[_0x3701('0xd')],'include':_0x6fc473[_0x3701('0xa')]?_[_0x3701('0xb')](_0x6fc473[_0x3701('0xa')],function(_0x16f979){return{'model':db[_0x16f979[_0x3701('0xc')]],'as':_0x16f979['as'],'attributes':_0x16f979[_0x3701('0xd')]};}):[]};}):[]};}):[]:[]})[_0x3701('0xe')](function(_0x264ea0){logger['info'](_0x3701('0xf'),_0x126900);logger[_0x3701('0x10')]('GetInterval',_0x126900,JSON[_0x3701('0x11')](_0x264ea0));_0x55c999(_0x264ea0);})[_0x3701('0x12')](function(_0x2b17bb){logger[_0x3701('0x13')](_0x3701('0xf'),_0x2b17bb[_0x3701('0x14')],_0x126900);_0x533303(_0x3d1f31[_0x3701('0x13')](0x1f4,_0x2b17bb[_0x3701('0x14')]));});});};exports[_0x3701('0x15')]=function(_0x5b37a3){var _0x507ac1=this;return new Promise(function(_0x35cd56,_0x4ec92f){return db[_0x3701('0x16')][_0x3701('0x17')]({'raw':_0x5b37a3[_0x3701('0x6')]?_0x5b37a3[_0x3701('0x6')][_0x3701('0x7')]===undefined?!![]:![]:!![],'where':_0x5b37a3[_0x3701('0x6')]?_0x5b37a3[_0x3701('0x6')]['where']||null:null,'attributes':_0x5b37a3[_0x3701('0x6')]?_0x5b37a3[_0x3701('0x6')][_0x3701('0xd')]||null:null,'include':_0x5b37a3[_0x3701('0x6')]?_0x5b37a3[_0x3701('0x6')][_0x3701('0xa')]?_[_0x3701('0xb')](_0x5b37a3['options']['include'],function(_0x29b0e9){return{'model':db[_0x29b0e9['model']],'as':_0x29b0e9['as'],'attributes':_0x29b0e9['attributes'],'include':_0x29b0e9['include']?_['map'](_0x29b0e9['include'],function(_0x14e8bc){return{'model':db[_0x14e8bc[_0x3701('0xc')]],'as':_0x14e8bc['as'],'attributes':_0x14e8bc[_0x3701('0xd')],'include':_0x14e8bc['include']?_[_0x3701('0xb')](_0x14e8bc[_0x3701('0xa')],function(_0x479e8a){return{'model':db[_0x479e8a[_0x3701('0xc')]],'as':_0x479e8a['as'],'attributes':_0x479e8a[_0x3701('0xd')]};}):[]};}):[]};}):[]:[]})[_0x3701('0xe')](function(_0x9d3379){logger[_0x3701('0x18')](_0x3701('0x15'),_0x5b37a3);logger['debug'](_0x3701('0x15'),_0x5b37a3,JSON[_0x3701('0x11')](_0x9d3379));_0x35cd56(_0x9d3379);})[_0x3701('0x12')](function(_0x103a7b){logger[_0x3701('0x13')]('ShowInterval',_0x103a7b[_0x3701('0x14')],_0x5b37a3);_0x4ec92f(_0x507ac1[_0x3701('0x13')](0x1f4,_0x103a7b[_0x3701('0x14')]));});});};function checkArrayOfIntervals(_0x229348,_0x20054f){var _0xd9c309=[];return db[_0x3701('0x16')][_0x3701('0x5')]({'where':{'id':_0x229348}})[_0x3701('0xe')](function(_0x41a7a5){_0xd9c309=_0x41a7a5;return Promise[_0x3701('0x19')](_0xd9c309[_0x3701('0xb')](function(_0x40152){return _0x40152[_0x3701('0x1a')](_0x20054f);}));})['then'](function(_0x25e6b2){var _0x34360e=_0x25e6b2[_0x3701('0x1b')](function(_0x140a96,_0x2cd2e8){return _0x140a96||_0x2cd2e8;},![]);logger[_0x3701('0x18')](util['format'](_0x3701('0x1c'),_0xd9c309[_0x3701('0xb')](function(_0x30aeff){return _0x30aeff[_0x3701('0x1d')];})['join'](',\x20'),_0xd9c309['map'](function(_0x4c47ea){return _0x4c47ea['id'];})[_0x3701('0x1e')](',\x20')));return _0x34360e;});}function checkSingleInterval(_0x9e8df4,_0x645a0){return db[_0x3701('0x16')][_0x3701('0x1f')](_0x9e8df4)[_0x3701('0xe')](function(_0x59a07b){if(_0x59a07b){logger['info'](util[_0x3701('0x20')](_0x3701('0x21'),_0x59a07b[_0x3701('0x1d')],_0x59a07b['id']));return _0x59a07b[_0x3701('0x1a')](_0x645a0);}});}exports[_0x3701('0x22')]=function(_0xe85b9f){var _0x2574e8=_0xe85b9f[_0x3701('0x23')];var _0x3705db=Array[_0x3701('0x24')](_0xe85b9f[_0x3701('0x25')])?_0xe85b9f[_0x3701('0x25')]:typeof _0xe85b9f[_0x3701('0x25')]===_0x3701('0x26')?[_0xe85b9f[_0x3701('0x25')]]:[];var _0x485eff=_0xe85b9f[_0x3701('0x27')]||undefined;var _0x48c066=![];if(_0x3705db[_0x3701('0x28')]){logger[_0x3701('0x18')](util[_0x3701('0x20')](_0x3701('0x29'),_0x3705db[_0x3701('0x1e')](';\x20')));}if(_0x485eff){logger[_0x3701('0x18')](util[_0x3701('0x20')]('IntervalIftime:\x20timezone\x20=\x20%s',_0x485eff));}logger[_0x3701('0x10')](_0x3701('0x2a'),_0x48c066);logger[_0x3701('0x2b')](_0x3701('0x22'),_0xe85b9f);return Promise['resolve']()[_0x3701('0xe')](function(){if(Array[_0x3701('0x24')](_0x2574e8)){return checkArrayOfIntervals(_0x2574e8,_0x485eff);}else if(_0x2574e8){return checkSingleInterval(_0x2574e8,_0x485eff);}})['then'](function(_0x2f9b98){var _0x3500a6=_0x3705db['reduce'](function(_0x5e8713,_0x22a88a){return _0x5e8713||iftime(_0x22a88a,_0x485eff);},![]);_0x48c066=_0x2f9b98||_0x3500a6;return _0x48c066;})[_0x3701('0x12')](function(_0x5ca465){logger['error'](_0x3701('0x22'),_0xe85b9f,_0x5ca465);throw this[_0x3701('0x13')](0x1f4,_0x5ca465[_0x3701('0x14')]);});};
\ No newline at end of file
+var _0x8272=['GetInterval','Interval','options','where','attributes','limit','include','map','model','then','info','stringify','catch','error','message','ShowInterval','find','raw','debug','findAll','all','ifTime','reduce','name','join','findById','format','IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)','intervalIds','isArray','intervals','string','length','IntervalIftime:\x20interval\x20strings\x20=\x20%s','IntervalIftime:\x20timezone\x20=\x20%s','Iftime','silly','IntervalIftime','resolve','util','../../mysqldb','../../utils/iftime','iftime','../../config/logger','rpc'];(function(_0x4e2596,_0x1ff134){var _0x3804de=function(_0x3cba73){while(--_0x3cba73){_0x4e2596['push'](_0x4e2596['shift']());}};_0x3804de(++_0x1ff134);}(_0x8272,0xdb));var _0x2827=function(_0x3e1294,_0x41791a){_0x3e1294=_0x3e1294-0x0;var _0x3bbca2=_0x8272[_0x3e1294];return _0x3bbca2;};'use strict';var _=require('lodash');var util=require(_0x2827('0x0'));var db=require(_0x2827('0x1'))['db'];var iftime=require(_0x2827('0x2'))[_0x2827('0x3')];var logger=require(_0x2827('0x4'))(_0x2827('0x5'));exports[_0x2827('0x6')]=function(_0x149520){var _0x276165=this;return new Promise(function(_0x21d70b,_0x273697){return db[_0x2827('0x7')]['findAll']({'raw':_0x149520['options']?_0x149520[_0x2827('0x8')]['raw']===undefined?!![]:![]:!![],'where':_0x149520[_0x2827('0x8')]?_0x149520[_0x2827('0x8')][_0x2827('0x9')]||null:null,'attributes':_0x149520[_0x2827('0x8')]?_0x149520[_0x2827('0x8')][_0x2827('0xa')]||null:null,'limit':_0x149520[_0x2827('0x8')]?_0x149520[_0x2827('0x8')][_0x2827('0xb')]||null:null,'include':_0x149520['options']?_0x149520[_0x2827('0x8')][_0x2827('0xc')]?_[_0x2827('0xd')](_0x149520[_0x2827('0x8')][_0x2827('0xc')],function(_0x256345){return{'model':db[_0x256345[_0x2827('0xe')]],'as':_0x256345['as'],'attributes':_0x256345[_0x2827('0xa')],'include':_0x256345[_0x2827('0xc')]?_[_0x2827('0xd')](_0x256345[_0x2827('0xc')],function(_0x173ee4){return{'model':db[_0x173ee4[_0x2827('0xe')]],'as':_0x173ee4['as'],'attributes':_0x173ee4[_0x2827('0xa')],'include':_0x173ee4['include']?_[_0x2827('0xd')](_0x173ee4['include'],function(_0x324e98){return{'model':db[_0x324e98[_0x2827('0xe')]],'as':_0x324e98['as'],'attributes':_0x324e98[_0x2827('0xa')]};}):[]};}):[]};}):[]:[]})[_0x2827('0xf')](function(_0x40c109){logger[_0x2827('0x10')]('GetInterval',_0x149520);logger['debug']('GetInterval',_0x149520,JSON[_0x2827('0x11')](_0x40c109));_0x21d70b(_0x40c109);})[_0x2827('0x12')](function(_0x92e0cb){logger[_0x2827('0x13')](_0x2827('0x6'),_0x92e0cb['message'],_0x149520);_0x273697(_0x276165[_0x2827('0x13')](0x1f4,_0x92e0cb[_0x2827('0x14')]));});});};exports[_0x2827('0x15')]=function(_0x546a2c){var _0x1b4828=this;return new Promise(function(_0x3496e3,_0x4cce70){return db[_0x2827('0x7')][_0x2827('0x16')]({'raw':_0x546a2c[_0x2827('0x8')]?_0x546a2c[_0x2827('0x8')][_0x2827('0x17')]===undefined?!![]:![]:!![],'where':_0x546a2c['options']?_0x546a2c[_0x2827('0x8')][_0x2827('0x9')]||null:null,'attributes':_0x546a2c[_0x2827('0x8')]?_0x546a2c['options'][_0x2827('0xa')]||null:null,'include':_0x546a2c['options']?_0x546a2c[_0x2827('0x8')][_0x2827('0xc')]?_[_0x2827('0xd')](_0x546a2c[_0x2827('0x8')][_0x2827('0xc')],function(_0x359cd6){return{'model':db[_0x359cd6[_0x2827('0xe')]],'as':_0x359cd6['as'],'attributes':_0x359cd6[_0x2827('0xa')],'include':_0x359cd6[_0x2827('0xc')]?_[_0x2827('0xd')](_0x359cd6['include'],function(_0x2bbfae){return{'model':db[_0x2bbfae['model']],'as':_0x2bbfae['as'],'attributes':_0x2bbfae['attributes'],'include':_0x2bbfae[_0x2827('0xc')]?_[_0x2827('0xd')](_0x2bbfae[_0x2827('0xc')],function(_0x2848bf){return{'model':db[_0x2848bf['model']],'as':_0x2848bf['as'],'attributes':_0x2848bf['attributes']};}):[]};}):[]};}):[]:[]})[_0x2827('0xf')](function(_0x47023a){logger[_0x2827('0x10')](_0x2827('0x15'),_0x546a2c);logger[_0x2827('0x18')](_0x2827('0x15'),_0x546a2c,JSON['stringify'](_0x47023a));_0x3496e3(_0x47023a);})[_0x2827('0x12')](function(_0xd5e7f0){logger[_0x2827('0x13')](_0x2827('0x15'),_0xd5e7f0[_0x2827('0x14')],_0x546a2c);_0x4cce70(_0x1b4828[_0x2827('0x13')](0x1f4,_0xd5e7f0[_0x2827('0x14')]));});});};function checkArrayOfIntervals(_0xabae98,_0x2979d4){var _0x2e12f3=[];return db['Interval'][_0x2827('0x19')]({'where':{'id':_0xabae98}})[_0x2827('0xf')](function(_0x3cb61c){_0x2e12f3=_0x3cb61c;return Promise[_0x2827('0x1a')](_0x2e12f3['map'](function(_0x4c68cc){return _0x4c68cc[_0x2827('0x1b')](_0x2979d4);}));})[_0x2827('0xf')](function(_0x2955ce){var _0x19096e=_0x2955ce[_0x2827('0x1c')](function(_0x325dfa,_0x5831f3){return _0x325dfa||_0x5831f3;},![]);logger['info'](util['format']('IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)',_0x2e12f3[_0x2827('0xd')](function(_0x251fa4){return _0x251fa4[_0x2827('0x1d')];})[_0x2827('0x1e')](',\x20'),_0x2e12f3[_0x2827('0xd')](function(_0x520386){return _0x520386['id'];})['join'](',\x20')));return _0x19096e;});}function checkSingleInterval(_0x3e9fcf,_0x4b272e){return db['Interval'][_0x2827('0x1f')](_0x3e9fcf)['then'](function(_0x3b1c5d){if(_0x3b1c5d){logger['info'](util[_0x2827('0x20')](_0x2827('0x21'),_0x3b1c5d['name'],_0x3b1c5d['id']));return _0x3b1c5d[_0x2827('0x1b')](_0x4b272e);}});}exports['IntervalIftime']=function(_0x4d1c13){var _0x474de8=_0x4d1c13[_0x2827('0x22')];var _0x45f691=Array[_0x2827('0x23')](_0x4d1c13[_0x2827('0x24')])?_0x4d1c13[_0x2827('0x24')]:typeof _0x4d1c13['intervals']===_0x2827('0x25')?[_0x4d1c13[_0x2827('0x24')]]:[];var _0x27356c=_0x4d1c13['timezone']||undefined;var _0x4d02dc=![];if(_0x45f691[_0x2827('0x26')]){logger['info'](util[_0x2827('0x20')](_0x2827('0x27'),_0x45f691[_0x2827('0x1e')](';\x20')));}if(_0x27356c){logger[_0x2827('0x10')](util[_0x2827('0x20')](_0x2827('0x28'),_0x27356c));}logger[_0x2827('0x18')](_0x2827('0x29'),_0x4d02dc);logger[_0x2827('0x2a')](_0x2827('0x2b'),_0x4d1c13);return Promise[_0x2827('0x2c')]()[_0x2827('0xf')](function(){if(Array['isArray'](_0x474de8)){return checkArrayOfIntervals(_0x474de8,_0x27356c);}else if(_0x474de8){return checkSingleInterval(_0x474de8,_0x27356c);}})['then'](function(_0x3efd1c){var _0x4f0ac5=_0x45f691[_0x2827('0x1c')](function(_0x5d81c1,_0x399d3c){return _0x5d81c1||iftime(_0x399d3c,_0x27356c);},![]);_0x4d02dc=_0x3efd1c||_0x4f0ac5;return _0x4d02dc;})['catch'](function(_0x2f30c8){logger[_0x2827('0x13')](_0x2827('0x2b'),_0x4d1c13,_0x2f30c8);throw this[_0x2827('0x13')](0x1f4,_0x2f30c8[_0x2827('0x14')]);});};
\ No newline at end of file