Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / interval / interval.rpc.js
index c5b196e..65d7be6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc37b=['include','map','model','attributes','ShowInterval','Interval','debug','lodash','util','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','Interval,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','GetInterval','findAll','options','raw','where','limit'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0xc37b,0x1e3));var _0xbc37=function(_0x187e86,_0x32720b){_0x187e86=_0x187e86-0x0;var _0x116388=_0xc37b[_0x187e86];return _0x116388;};'use strict';var _=require(_0xbc37('0x0'));var util=require(_0xbc37('0x1'));var moment=require('moment');var BPromise=require(_0xbc37('0x2'));var rs=require(_0xbc37('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbc37('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xbc37('0x5'))('rpc');var config=require(_0xbc37('0x6'));var jayson=require(_0xbc37('0x7'));var client=jayson[_0xbc37('0x8')][_0xbc37('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x53134f,_0x226f95,_0x5e6d7a){return new BPromise(function(_0x1b7bfd,_0x1db41e){return client[_0xbc37('0xa')](_0x53134f,_0x5e6d7a)[_0xbc37('0xb')](function(_0x2b9842){logger['info'](_0xbc37('0xc'),_0x226f95,_0xbc37('0xd'));logger['debug']('Interval,\x20%s,\x20%s,\x20%s',_0x226f95,_0xbc37('0xd'),JSON[_0xbc37('0xe')](_0x2b9842));if(_0x2b9842[_0xbc37('0xf')]){if(_0x2b9842[_0xbc37('0xf')][_0xbc37('0x10')]===0x1f4){logger[_0xbc37('0xf')](_0xbc37('0xc'),_0x226f95,_0x2b9842['error'][_0xbc37('0x11')]);return _0x1db41e(_0x2b9842['error'][_0xbc37('0x11')]);}logger['error']('Interval,\x20%s,\x20%s',_0x226f95,_0x2b9842[_0xbc37('0xf')][_0xbc37('0x11')]);return _0x1b7bfd(_0x2b9842[_0xbc37('0xf')][_0xbc37('0x11')]);}else{logger[_0xbc37('0x12')](_0xbc37('0xc'),_0x226f95,'request\x20sent');_0x1b7bfd(_0x2b9842[_0xbc37('0x13')][_0xbc37('0x11')]);}})[_0xbc37('0x14')](function(_0x1a37d0){logger[_0xbc37('0xf')](_0xbc37('0xc'),_0x226f95,_0x1a37d0);_0x1db41e(_0x1a37d0);});});}exports[_0xbc37('0x15')]=function(_0x5e98d5){var _0x555fe6=this;return new Promise(function(_0x242f48,_0x3fe8ee){return db['Interval'][_0xbc37('0x16')]({'raw':_0x5e98d5[_0xbc37('0x17')]?_0x5e98d5[_0xbc37('0x17')][_0xbc37('0x18')]===undefined?!![]:![]:!![],'where':_0x5e98d5[_0xbc37('0x17')]?_0x5e98d5[_0xbc37('0x17')][_0xbc37('0x19')]||null:null,'attributes':_0x5e98d5[_0xbc37('0x17')]?_0x5e98d5['options']['attributes']||null:null,'limit':_0x5e98d5[_0xbc37('0x17')]?_0x5e98d5[_0xbc37('0x17')][_0xbc37('0x1a')]||null:null,'include':_0x5e98d5['options']?_0x5e98d5[_0xbc37('0x17')][_0xbc37('0x1b')]?_[_0xbc37('0x1c')](_0x5e98d5[_0xbc37('0x17')]['include'],function(_0x585e93){return{'model':db[_0x585e93[_0xbc37('0x1d')]],'as':_0x585e93['as'],'attributes':_0x585e93[_0xbc37('0x1e')],'include':_0x585e93['include']?_[_0xbc37('0x1c')](_0x585e93[_0xbc37('0x1b')],function(_0xc0ee46){return{'model':db[_0xc0ee46['model']],'as':_0xc0ee46['as'],'attributes':_0xc0ee46[_0xbc37('0x1e')],'include':_0xc0ee46[_0xbc37('0x1b')]?_[_0xbc37('0x1c')](_0xc0ee46[_0xbc37('0x1b')],function(_0x749cb2){return{'model':db[_0x749cb2[_0xbc37('0x1d')]],'as':_0x749cb2['as'],'attributes':_0x749cb2[_0xbc37('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xbc37('0xb')](function(_0x475915){logger[_0xbc37('0x12')](_0xbc37('0x15'),_0x5e98d5);logger['debug']('GetInterval',_0x5e98d5,JSON[_0xbc37('0xe')](_0x475915));_0x242f48(_0x475915);})[_0xbc37('0x14')](function(_0x417568){logger['error']('GetInterval',_0x417568['message'],_0x5e98d5);_0x3fe8ee(_0x555fe6['error'](0x1f4,_0x417568[_0xbc37('0x11')]));});});};exports[_0xbc37('0x1f')]=function(_0x92a005){var _0x244e51=this;return new Promise(function(_0x1bc270,_0x393dd7){return db[_0xbc37('0x20')]['find']({'raw':_0x92a005['options']?_0x92a005[_0xbc37('0x17')][_0xbc37('0x18')]===undefined?!![]:![]:!![],'where':_0x92a005[_0xbc37('0x17')]?_0x92a005['options'][_0xbc37('0x19')]||null:null,'attributes':_0x92a005[_0xbc37('0x17')]?_0x92a005[_0xbc37('0x17')][_0xbc37('0x1e')]||null:null,'include':_0x92a005[_0xbc37('0x17')]?_0x92a005[_0xbc37('0x17')][_0xbc37('0x1b')]?_[_0xbc37('0x1c')](_0x92a005['options']['include'],function(_0x13e8dc){return{'model':db[_0x13e8dc['model']],'as':_0x13e8dc['as'],'attributes':_0x13e8dc['attributes'],'include':_0x13e8dc['include']?_[_0xbc37('0x1c')](_0x13e8dc[_0xbc37('0x1b')],function(_0x55ec7a){return{'model':db[_0x55ec7a[_0xbc37('0x1d')]],'as':_0x55ec7a['as'],'attributes':_0x55ec7a[_0xbc37('0x1e')],'include':_0x55ec7a[_0xbc37('0x1b')]?_['map'](_0x55ec7a[_0xbc37('0x1b')],function(_0x40fa80){return{'model':db[_0x40fa80['model']],'as':_0x40fa80['as'],'attributes':_0x40fa80[_0xbc37('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2e4c85){logger[_0xbc37('0x12')]('ShowInterval',_0x92a005);logger[_0xbc37('0x21')](_0xbc37('0x1f'),_0x92a005,JSON[_0xbc37('0xe')](_0x2e4c85));_0x1bc270(_0x2e4c85);})[_0xbc37('0x14')](function(_0x3626fd){logger[_0xbc37('0xf')](_0xbc37('0x1f'),_0x3626fd[_0xbc37('0x11')],_0x92a005);_0x393dd7(_0x244e51[_0xbc37('0xf')](0x1f4,_0x3626fd['message']));});});};
\ No newline at end of file
+var _0x8945=['intervals','string','timezone','IntervalIftime:\x20interval\x20strings\x20=\x20%s','IntervalIftime:\x20timezone\x20=\x20%s','Iftime','resolve','lodash','../../mysqldb','../../utils/iftime','iftime','../../config/logger','rpc','GetInterval','Interval','findAll','options','where','include','model','attributes','map','then','info','stringify','error','message','find','ShowInterval','catch','all','ifTime','format','name','join','findById','IntervalIftime','intervalIds','isArray'];(function(_0x46698a,_0x8de1e4){var _0x356db0=function(_0x19e83c){while(--_0x19e83c){_0x46698a['push'](_0x46698a['shift']());}};_0x356db0(++_0x8de1e4);}(_0x8945,0x18d));var _0x5894=function(_0x5c7753,_0x25dbc9){_0x5c7753=_0x5c7753-0x0;var _0x4d7dbf=_0x8945[_0x5c7753];return _0x4d7dbf;};'use strict';var _=require(_0x5894('0x0'));var util=require('util');var db=require(_0x5894('0x1'))['db'];var iftime=require(_0x5894('0x2'))[_0x5894('0x3')];var logger=require(_0x5894('0x4'))(_0x5894('0x5'));exports[_0x5894('0x6')]=function(_0x340d5d){var _0x5eee15=this;return new Promise(function(_0x5cca8a,_0x714ed1){return db[_0x5894('0x7')][_0x5894('0x8')]({'raw':_0x340d5d[_0x5894('0x9')]?_0x340d5d[_0x5894('0x9')]['raw']===undefined?!![]:![]:!![],'where':_0x340d5d[_0x5894('0x9')]?_0x340d5d[_0x5894('0x9')][_0x5894('0xa')]||null:null,'attributes':_0x340d5d[_0x5894('0x9')]?_0x340d5d[_0x5894('0x9')]['attributes']||null:null,'limit':_0x340d5d[_0x5894('0x9')]?_0x340d5d[_0x5894('0x9')]['limit']||null:null,'include':_0x340d5d[_0x5894('0x9')]?_0x340d5d[_0x5894('0x9')]['include']?_['map'](_0x340d5d['options'][_0x5894('0xb')],function(_0x8d2aab){return{'model':db[_0x8d2aab[_0x5894('0xc')]],'as':_0x8d2aab['as'],'attributes':_0x8d2aab[_0x5894('0xd')],'include':_0x8d2aab[_0x5894('0xb')]?_[_0x5894('0xe')](_0x8d2aab[_0x5894('0xb')],function(_0xaad43e){return{'model':db[_0xaad43e[_0x5894('0xc')]],'as':_0xaad43e['as'],'attributes':_0xaad43e['attributes'],'include':_0xaad43e[_0x5894('0xb')]?_['map'](_0xaad43e[_0x5894('0xb')],function(_0x1a484e){return{'model':db[_0x1a484e[_0x5894('0xc')]],'as':_0x1a484e['as'],'attributes':_0x1a484e[_0x5894('0xd')]};}):[]};}):[]};}):[]:[]})[_0x5894('0xf')](function(_0x12c6a2){logger[_0x5894('0x10')](_0x5894('0x6'),_0x340d5d);logger['debug'](_0x5894('0x6'),_0x340d5d,JSON[_0x5894('0x11')](_0x12c6a2));_0x5cca8a(_0x12c6a2);})['catch'](function(_0x4182c2){logger[_0x5894('0x12')]('GetInterval',_0x4182c2[_0x5894('0x13')],_0x340d5d);_0x714ed1(_0x5eee15[_0x5894('0x12')](0x1f4,_0x4182c2[_0x5894('0x13')]));});});};exports['ShowInterval']=function(_0x50f33b){var _0x44ded4=this;return new Promise(function(_0x3b9e45,_0xc5d981){return db[_0x5894('0x7')][_0x5894('0x14')]({'raw':_0x50f33b[_0x5894('0x9')]?_0x50f33b[_0x5894('0x9')]['raw']===undefined?!![]:![]:!![],'where':_0x50f33b['options']?_0x50f33b[_0x5894('0x9')][_0x5894('0xa')]||null:null,'attributes':_0x50f33b[_0x5894('0x9')]?_0x50f33b[_0x5894('0x9')][_0x5894('0xd')]||null:null,'include':_0x50f33b[_0x5894('0x9')]?_0x50f33b[_0x5894('0x9')][_0x5894('0xb')]?_[_0x5894('0xe')](_0x50f33b[_0x5894('0x9')]['include'],function(_0x3beab1){return{'model':db[_0x3beab1[_0x5894('0xc')]],'as':_0x3beab1['as'],'attributes':_0x3beab1[_0x5894('0xd')],'include':_0x3beab1[_0x5894('0xb')]?_[_0x5894('0xe')](_0x3beab1[_0x5894('0xb')],function(_0x5e8c0b){return{'model':db[_0x5e8c0b[_0x5894('0xc')]],'as':_0x5e8c0b['as'],'attributes':_0x5e8c0b[_0x5894('0xd')],'include':_0x5e8c0b[_0x5894('0xb')]?_[_0x5894('0xe')](_0x5e8c0b[_0x5894('0xb')],function(_0xefd41a){return{'model':db[_0xefd41a[_0x5894('0xc')]],'as':_0xefd41a['as'],'attributes':_0xefd41a[_0x5894('0xd')]};}):[]};}):[]};}):[]:[]})[_0x5894('0xf')](function(_0x3d654f){logger['info'](_0x5894('0x15'),_0x50f33b);logger['debug']('ShowInterval',_0x50f33b,JSON['stringify'](_0x3d654f));_0x3b9e45(_0x3d654f);})[_0x5894('0x16')](function(_0x721228){logger['error'](_0x5894('0x15'),_0x721228[_0x5894('0x13')],_0x50f33b);_0xc5d981(_0x44ded4[_0x5894('0x12')](0x1f4,_0x721228[_0x5894('0x13')]));});});};function checkArrayOfIntervals(_0x17bd13,_0x19b60e){var _0x254baf=[];return db['Interval'][_0x5894('0x8')]({'where':{'id':_0x17bd13}})[_0x5894('0xf')](function(_0x1e3f29){_0x254baf=_0x1e3f29;return Promise[_0x5894('0x17')](_0x254baf[_0x5894('0xe')](function(_0x5cd692){return _0x5cd692[_0x5894('0x18')](_0x19b60e);}));})['then'](function(_0x8ae036){var _0x324dad=_0x8ae036['reduce'](function(_0x52563c,_0x4c07a0){return _0x52563c||_0x4c07a0;},![]);logger[_0x5894('0x10')](util[_0x5894('0x19')]('IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)',_0x254baf[_0x5894('0xe')](function(_0x5f1499){return _0x5f1499[_0x5894('0x1a')];})[_0x5894('0x1b')](',\x20'),_0x254baf['map'](function(_0x4898ad){return _0x4898ad['id'];})['join'](',\x20')));return _0x324dad;});}function checkSingleInterval(_0xf065f7,_0x1898ea){return db['Interval'][_0x5894('0x1c')](_0xf065f7)['then'](function(_0x280682){if(_0x280682){logger['info'](util['format']('IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)',_0x280682[_0x5894('0x1a')],_0x280682['id']));return _0x280682[_0x5894('0x18')](_0x1898ea);}});}exports[_0x5894('0x1d')]=function(_0x25d39a){var _0x466738=_0x25d39a[_0x5894('0x1e')];var _0x5afd7a=Array[_0x5894('0x1f')](_0x25d39a['intervals'])?_0x25d39a[_0x5894('0x20')]:typeof _0x25d39a['intervals']===_0x5894('0x21')?[_0x25d39a[_0x5894('0x20')]]:[];var _0x2cd476=_0x25d39a[_0x5894('0x22')]||undefined;var _0x353b73=![];if(_0x5afd7a['length']){logger[_0x5894('0x10')](util[_0x5894('0x19')](_0x5894('0x23'),_0x5afd7a[_0x5894('0x1b')](';\x20')));}if(_0x2cd476){logger[_0x5894('0x10')](util[_0x5894('0x19')](_0x5894('0x24'),_0x2cd476));}logger['debug'](_0x5894('0x25'),_0x353b73);logger['silly']('IntervalIftime',_0x25d39a);return Promise[_0x5894('0x26')]()[_0x5894('0xf')](function(){if(Array[_0x5894('0x1f')](_0x466738)){return checkArrayOfIntervals(_0x466738,_0x2cd476);}else if(_0x466738){return checkSingleInterval(_0x466738,_0x2cd476);}})[_0x5894('0xf')](function(_0x3d0321){var _0x24d436=_0x5afd7a['reduce'](function(_0x31e136,_0x3d929b){return _0x31e136||iftime(_0x3d929b,_0x2cd476);},![]);_0x353b73=_0x3d0321||_0x24d436;return _0x353b73;})[_0x5894('0x16')](function(_0xccf5ed){logger[_0x5894('0x12')](_0x5894('0x1d'),_0x25d39a,_0xccf5ed);throw this['error'](0x1f4,_0xccf5ed[_0x5894('0x13')]);});};
\ No newline at end of file