Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / interval / interval.rpc.js
index 85d71ef..6d6f13b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd21e=['rpc','../../config/environment','client','http','request','then','info','request\x20sent','Interval,\x20%s,\x20%s,\x20%s','stringify','error','code','Interval,\x20%s,\x20%s','message','result','catch','GetInterval','Interval','options','limit','include','map','model','attributes','debug','find','raw','where','ShowInterval','util','moment','bluebird','randomstring','../../config/utils'];(function(_0x44d809,_0x1f76fb){var _0x5361b9=function(_0x3e2a7f){while(--_0x3e2a7f){_0x44d809['push'](_0x44d809['shift']());}};_0x5361b9(++_0x1f76fb);}(_0xd21e,0x14f));var _0xed21=function(_0x1111fb,_0x2cba49){_0x1111fb=_0x1111fb-0x0;var _0x5b12f9=_0xd21e[_0x1111fb];return _0x5b12f9;};'use strict';var _=require('lodash');var util=require(_0xed21('0x0'));var moment=require(_0xed21('0x1'));var BPromise=require(_0xed21('0x2'));var rs=require(_0xed21('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xed21('0x4'));var logger=require('../../config/logger')(_0xed21('0x5'));var config=require(_0xed21('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xed21('0x7')][_0xed21('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5c588d,_0x57f312,_0x1d4deb){return new BPromise(function(_0x446fa5,_0x130e11){return client[_0xed21('0x9')](_0x5c588d,_0x1d4deb)[_0xed21('0xa')](function(_0x9c9b78){logger[_0xed21('0xb')]('Interval,\x20%s,\x20%s',_0x57f312,_0xed21('0xc'));logger['debug'](_0xed21('0xd'),_0x57f312,'request\x20sent',JSON[_0xed21('0xe')](_0x9c9b78));if(_0x9c9b78[_0xed21('0xf')]){if(_0x9c9b78[_0xed21('0xf')][_0xed21('0x10')]===0x1f4){logger['error'](_0xed21('0x11'),_0x57f312,_0x9c9b78[_0xed21('0xf')]['message']);return _0x130e11(_0x9c9b78[_0xed21('0xf')]['message']);}logger[_0xed21('0xf')](_0xed21('0x11'),_0x57f312,_0x9c9b78[_0xed21('0xf')][_0xed21('0x12')]);return _0x446fa5(_0x9c9b78['error'][_0xed21('0x12')]);}else{logger['info'](_0xed21('0x11'),_0x57f312,'request\x20sent');_0x446fa5(_0x9c9b78[_0xed21('0x13')]['message']);}})[_0xed21('0x14')](function(_0x34d7b4){logger['error'](_0xed21('0x11'),_0x57f312,_0x34d7b4);_0x130e11(_0x34d7b4);});});}exports[_0xed21('0x15')]=function(_0xbac9bd){var _0x26952e=this;return new Promise(function(_0x50b6b9,_0x2c3196){return db[_0xed21('0x16')]['findAll']({'raw':_0xbac9bd[_0xed21('0x17')]?_0xbac9bd[_0xed21('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0xbac9bd['options']?_0xbac9bd[_0xed21('0x17')]['where']||null:null,'attributes':_0xbac9bd['options']?_0xbac9bd[_0xed21('0x17')]['attributes']||null:null,'limit':_0xbac9bd[_0xed21('0x17')]?_0xbac9bd[_0xed21('0x17')][_0xed21('0x18')]||null:null,'include':_0xbac9bd[_0xed21('0x17')]?_0xbac9bd['options'][_0xed21('0x19')]?_[_0xed21('0x1a')](_0xbac9bd[_0xed21('0x17')][_0xed21('0x19')],function(_0x10e756){return{'model':db[_0x10e756[_0xed21('0x1b')]],'as':_0x10e756['as'],'attributes':_0x10e756[_0xed21('0x1c')],'include':_0x10e756[_0xed21('0x19')]?_[_0xed21('0x1a')](_0x10e756[_0xed21('0x19')],function(_0x117adb){return{'model':db[_0x117adb[_0xed21('0x1b')]],'as':_0x117adb['as'],'attributes':_0x117adb[_0xed21('0x1c')],'include':_0x117adb[_0xed21('0x19')]?_[_0xed21('0x1a')](_0x117adb[_0xed21('0x19')],function(_0x2dbccd){return{'model':db[_0x2dbccd['model']],'as':_0x2dbccd['as'],'attributes':_0x2dbccd[_0xed21('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xed21('0xa')](function(_0x3c2164){logger[_0xed21('0xb')]('GetInterval',_0xbac9bd);logger[_0xed21('0x1d')](_0xed21('0x15'),_0xbac9bd,JSON[_0xed21('0xe')](_0x3c2164));_0x50b6b9(_0x3c2164);})[_0xed21('0x14')](function(_0x579ad4){logger[_0xed21('0xf')](_0xed21('0x15'),_0x579ad4[_0xed21('0x12')],_0xbac9bd);_0x2c3196(_0x26952e[_0xed21('0xf')](0x1f4,_0x579ad4['message']));});});};exports['ShowInterval']=function(_0x207cda){var _0x844c63=this;return new Promise(function(_0x35e92f,_0x306468){return db[_0xed21('0x16')][_0xed21('0x1e')]({'raw':_0x207cda[_0xed21('0x17')]?_0x207cda[_0xed21('0x17')][_0xed21('0x1f')]===undefined?!![]:![]:!![],'where':_0x207cda[_0xed21('0x17')]?_0x207cda['options'][_0xed21('0x20')]||null:null,'attributes':_0x207cda['options']?_0x207cda['options'][_0xed21('0x1c')]||null:null,'include':_0x207cda[_0xed21('0x17')]?_0x207cda[_0xed21('0x17')][_0xed21('0x19')]?_[_0xed21('0x1a')](_0x207cda[_0xed21('0x17')]['include'],function(_0x7c1bb6){return{'model':db[_0x7c1bb6[_0xed21('0x1b')]],'as':_0x7c1bb6['as'],'attributes':_0x7c1bb6[_0xed21('0x1c')],'include':_0x7c1bb6[_0xed21('0x19')]?_[_0xed21('0x1a')](_0x7c1bb6[_0xed21('0x19')],function(_0x16361e){return{'model':db[_0x16361e['model']],'as':_0x16361e['as'],'attributes':_0x16361e[_0xed21('0x1c')],'include':_0x16361e['include']?_[_0xed21('0x1a')](_0x16361e['include'],function(_0x2e4fe7){return{'model':db[_0x2e4fe7[_0xed21('0x1b')]],'as':_0x2e4fe7['as'],'attributes':_0x2e4fe7['attributes']};}):[]};}):[]};}):[]:[]})[_0xed21('0xa')](function(_0x3a41e3){logger[_0xed21('0xb')]('ShowInterval',_0x207cda);logger[_0xed21('0x1d')](_0xed21('0x21'),_0x207cda,JSON[_0xed21('0xe')](_0x3a41e3));_0x35e92f(_0x3a41e3);})['catch'](function(_0x33a78f){logger[_0xed21('0xf')]('ShowInterval',_0x33a78f[_0xed21('0x12')],_0x207cda);_0x306468(_0x844c63['error'](0x1f4,_0x33a78f[_0xed21('0x12')]));});});};
\ No newline at end of file
+var _0x390a=['name','join','IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)','IntervalIftime','isArray','intervals','string','timezone','length','IntervalIftime:\x20timezone\x20=\x20%s','silly','resolve','lodash','../../mysqldb','../../utils/iftime','iftime','rpc','GetInterval','Interval','findAll','options','raw','where','attributes','limit','map','include','model','then','info','stringify','catch','error','message','ShowInterval','debug','all','ifTime','reduce','format','IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)'];(function(_0x7d579a,_0x1580b){var _0x3b06cb=function(_0x4ba063){while(--_0x4ba063){_0x7d579a['push'](_0x7d579a['shift']());}};_0x3b06cb(++_0x1580b);}(_0x390a,0xb0));var _0xa390=function(_0x1223f2,_0x574895){_0x1223f2=_0x1223f2-0x0;var _0x381ff8=_0x390a[_0x1223f2];return _0x381ff8;};'use strict';var _=require(_0xa390('0x0'));var util=require('util');var db=require(_0xa390('0x1'))['db'];var iftime=require(_0xa390('0x2'))[_0xa390('0x3')];var logger=require('../../config/logger')(_0xa390('0x4'));exports[_0xa390('0x5')]=function(_0x3397b3){var _0x4f8ee1=this;return new Promise(function(_0x5aefe5,_0x1a9f16){return db[_0xa390('0x6')][_0xa390('0x7')]({'raw':_0x3397b3[_0xa390('0x8')]?_0x3397b3[_0xa390('0x8')][_0xa390('0x9')]===undefined?!![]:![]:!![],'where':_0x3397b3[_0xa390('0x8')]?_0x3397b3['options'][_0xa390('0xa')]||null:null,'attributes':_0x3397b3[_0xa390('0x8')]?_0x3397b3['options'][_0xa390('0xb')]||null:null,'limit':_0x3397b3[_0xa390('0x8')]?_0x3397b3[_0xa390('0x8')][_0xa390('0xc')]||null:null,'include':_0x3397b3[_0xa390('0x8')]?_0x3397b3[_0xa390('0x8')]['include']?_[_0xa390('0xd')](_0x3397b3[_0xa390('0x8')][_0xa390('0xe')],function(_0x1d185a){return{'model':db[_0x1d185a['model']],'as':_0x1d185a['as'],'attributes':_0x1d185a[_0xa390('0xb')],'include':_0x1d185a[_0xa390('0xe')]?_[_0xa390('0xd')](_0x1d185a[_0xa390('0xe')],function(_0x5d4a0a){return{'model':db[_0x5d4a0a[_0xa390('0xf')]],'as':_0x5d4a0a['as'],'attributes':_0x5d4a0a[_0xa390('0xb')],'include':_0x5d4a0a[_0xa390('0xe')]?_['map'](_0x5d4a0a[_0xa390('0xe')],function(_0x41bb65){return{'model':db[_0x41bb65[_0xa390('0xf')]],'as':_0x41bb65['as'],'attributes':_0x41bb65[_0xa390('0xb')]};}):[]};}):[]};}):[]:[]})[_0xa390('0x10')](function(_0x13b06e){logger[_0xa390('0x11')](_0xa390('0x5'),_0x3397b3);logger['debug'](_0xa390('0x5'),_0x3397b3,JSON[_0xa390('0x12')](_0x13b06e));_0x5aefe5(_0x13b06e);})[_0xa390('0x13')](function(_0x33599c){logger[_0xa390('0x14')](_0xa390('0x5'),_0x33599c[_0xa390('0x15')],_0x3397b3);_0x1a9f16(_0x4f8ee1[_0xa390('0x14')](0x1f4,_0x33599c['message']));});});};exports[_0xa390('0x16')]=function(_0x575153){var _0x533b85=this;return new Promise(function(_0x3ea645,_0xff9657){return db[_0xa390('0x6')]['find']({'raw':_0x575153['options']?_0x575153[_0xa390('0x8')][_0xa390('0x9')]===undefined?!![]:![]:!![],'where':_0x575153[_0xa390('0x8')]?_0x575153['options'][_0xa390('0xa')]||null:null,'attributes':_0x575153[_0xa390('0x8')]?_0x575153[_0xa390('0x8')]['attributes']||null:null,'include':_0x575153[_0xa390('0x8')]?_0x575153[_0xa390('0x8')][_0xa390('0xe')]?_[_0xa390('0xd')](_0x575153[_0xa390('0x8')]['include'],function(_0x5075a8){return{'model':db[_0x5075a8[_0xa390('0xf')]],'as':_0x5075a8['as'],'attributes':_0x5075a8['attributes'],'include':_0x5075a8[_0xa390('0xe')]?_[_0xa390('0xd')](_0x5075a8[_0xa390('0xe')],function(_0x4b1b97){return{'model':db[_0x4b1b97['model']],'as':_0x4b1b97['as'],'attributes':_0x4b1b97[_0xa390('0xb')],'include':_0x4b1b97[_0xa390('0xe')]?_[_0xa390('0xd')](_0x4b1b97[_0xa390('0xe')],function(_0x3785c7){return{'model':db[_0x3785c7[_0xa390('0xf')]],'as':_0x3785c7['as'],'attributes':_0x3785c7[_0xa390('0xb')]};}):[]};}):[]};}):[]:[]})[_0xa390('0x10')](function(_0xf4b8e2){logger[_0xa390('0x11')](_0xa390('0x16'),_0x575153);logger[_0xa390('0x17')](_0xa390('0x16'),_0x575153,JSON['stringify'](_0xf4b8e2));_0x3ea645(_0xf4b8e2);})[_0xa390('0x13')](function(_0x2f24ce){logger[_0xa390('0x14')]('ShowInterval',_0x2f24ce[_0xa390('0x15')],_0x575153);_0xff9657(_0x533b85[_0xa390('0x14')](0x1f4,_0x2f24ce['message']));});});};function checkArrayOfIntervals(_0x229f44,_0x449c93){var _0x2949b9=[];return db[_0xa390('0x6')]['findAll']({'where':{'id':_0x229f44}})['then'](function(_0x3625c1){_0x2949b9=_0x3625c1;return Promise[_0xa390('0x18')](_0x2949b9['map'](function(_0x32a6ff){return _0x32a6ff[_0xa390('0x19')](_0x449c93);}));})['then'](function(_0x58bedc){var _0x15f177=_0x58bedc[_0xa390('0x1a')](function(_0x4d1fa1,_0x3f30db){return _0x4d1fa1||_0x3f30db;},![]);logger[_0xa390('0x11')](util[_0xa390('0x1b')](_0xa390('0x1c'),_0x2949b9['map'](function(_0x50bc2d){return _0x50bc2d[_0xa390('0x1d')];})[_0xa390('0x1e')](',\x20'),_0x2949b9[_0xa390('0xd')](function(_0x97655f){return _0x97655f['id'];})[_0xa390('0x1e')](',\x20')));return _0x15f177;});}function checkSingleInterval(_0x57cd6e,_0x5c9088){return db[_0xa390('0x6')]['findById'](_0x57cd6e)[_0xa390('0x10')](function(_0x4a9f03){if(_0x4a9f03){logger['info'](util[_0xa390('0x1b')](_0xa390('0x1f'),_0x4a9f03[_0xa390('0x1d')],_0x4a9f03['id']));return _0x4a9f03[_0xa390('0x19')](_0x5c9088);}});}exports[_0xa390('0x20')]=function(_0x583291){var _0x47ff06=_0x583291['intervalIds'];var _0x3dd395=Array[_0xa390('0x21')](_0x583291[_0xa390('0x22')])?_0x583291[_0xa390('0x22')]:typeof _0x583291[_0xa390('0x22')]===_0xa390('0x23')?[_0x583291[_0xa390('0x22')]]:[];var _0x56f801=_0x583291[_0xa390('0x24')]||undefined;var _0x555f90=![];if(_0x3dd395[_0xa390('0x25')]){logger[_0xa390('0x11')](util[_0xa390('0x1b')]('IntervalIftime:\x20interval\x20strings\x20=\x20%s',_0x3dd395['join'](';\x20')));}if(_0x56f801){logger[_0xa390('0x11')](util[_0xa390('0x1b')](_0xa390('0x26'),_0x56f801));}logger['debug']('Iftime',_0x555f90);logger[_0xa390('0x27')](_0xa390('0x20'),_0x583291);return Promise[_0xa390('0x28')]()[_0xa390('0x10')](function(){if(Array['isArray'](_0x47ff06)){return checkArrayOfIntervals(_0x47ff06,_0x56f801);}else if(_0x47ff06){return checkSingleInterval(_0x47ff06,_0x56f801);}})[_0xa390('0x10')](function(_0x2fb1b4){var _0x446944=_0x3dd395[_0xa390('0x1a')](function(_0x7c4c49,_0x539d83){return _0x7c4c49||iftime(_0x539d83,_0x56f801);},![]);_0x555f90=_0x2fb1b4||_0x446944;return _0x555f90;})[_0xa390('0x13')](function(_0x2ec08b){logger[_0xa390('0x14')](_0xa390('0x20'),_0x583291,_0x2ec08b);throw this[_0xa390('0x14')](0x1f4,_0x2ec08b[_0xa390('0x15')]);});};
\ No newline at end of file