Built motion from commit (unavailable).|2.5.5
[motion2.git] / server / api / interval / interval.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xaae6=['model','then','ShowInterval','Interval','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','info','Interval,\x20%s,\x20%s','request\x20sent','debug','Interval,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetInterval','findAll','options','raw','where','attributes','limit','map','include'];(function(_0x47f7cf,_0x53179e){var _0x448df6=function(_0x4a947c){while(--_0x4a947c){_0x47f7cf['push'](_0x47f7cf['shift']());}};_0x448df6(++_0x53179e);}(_0xaae6,0x1a8));var _0x6aae=function(_0xdac242,_0x405bff){_0xdac242=_0xdac242-0x0;var _0x4637c4=_0xaae6[_0xdac242];return _0x4637c4;};'use strict';var _=require(_0x6aae('0x0'));var util=require('util');var moment=require(_0x6aae('0x1'));var BPromise=require(_0x6aae('0x2'));var rs=require(_0x6aae('0x3'));var fs=require('fs');var Redis=require(_0x6aae('0x4'));var db=require(_0x6aae('0x5'))['db'];var utils=require(_0x6aae('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x6aae('0x7'));var jayson=require(_0x6aae('0x8'));var client=jayson[_0x6aae('0x9')][_0x6aae('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x524875,_0x586782,_0xf5916f){return new BPromise(function(_0x32e50d,_0x3b6faa){return client[_0x6aae('0xb')](_0x524875,_0xf5916f)['then'](function(_0x2e0538){logger[_0x6aae('0xc')](_0x6aae('0xd'),_0x586782,_0x6aae('0xe'));logger[_0x6aae('0xf')](_0x6aae('0x10'),_0x586782,_0x6aae('0xe'),JSON[_0x6aae('0x11')](_0x2e0538));if(_0x2e0538[_0x6aae('0x12')]){if(_0x2e0538['error']['code']===0x1f4){logger['error'](_0x6aae('0xd'),_0x586782,_0x2e0538[_0x6aae('0x12')][_0x6aae('0x13')]);return _0x3b6faa(_0x2e0538[_0x6aae('0x12')][_0x6aae('0x13')]);}logger['error'](_0x6aae('0xd'),_0x586782,_0x2e0538[_0x6aae('0x12')][_0x6aae('0x13')]);return _0x32e50d(_0x2e0538[_0x6aae('0x12')][_0x6aae('0x13')]);}else{logger[_0x6aae('0xc')](_0x6aae('0xd'),_0x586782,_0x6aae('0xe'));_0x32e50d(_0x2e0538[_0x6aae('0x14')][_0x6aae('0x13')]);}})[_0x6aae('0x15')](function(_0x2d3c9b){logger[_0x6aae('0x12')](_0x6aae('0xd'),_0x586782,_0x2d3c9b);_0x3b6faa(_0x2d3c9b);});});}exports[_0x6aae('0x16')]=function(_0x33284c){var _0x120d37=this;return new Promise(function(_0x2ef33c,_0xf684cc){return db['Interval'][_0x6aae('0x17')]({'raw':_0x33284c[_0x6aae('0x18')]?_0x33284c[_0x6aae('0x18')][_0x6aae('0x19')]===undefined?!![]:![]:!![],'where':_0x33284c['options']?_0x33284c[_0x6aae('0x18')][_0x6aae('0x1a')]||null:null,'attributes':_0x33284c[_0x6aae('0x18')]?_0x33284c[_0x6aae('0x18')][_0x6aae('0x1b')]||null:null,'limit':_0x33284c['options']?_0x33284c[_0x6aae('0x18')][_0x6aae('0x1c')]||null:null,'include':_0x33284c[_0x6aae('0x18')]?_0x33284c['options']['include']?_[_0x6aae('0x1d')](_0x33284c[_0x6aae('0x18')][_0x6aae('0x1e')],function(_0x1e45ad){return{'model':db[_0x1e45ad[_0x6aae('0x1f')]],'as':_0x1e45ad['as'],'attributes':_0x1e45ad[_0x6aae('0x1b')],'include':_0x1e45ad[_0x6aae('0x1e')]?_['map'](_0x1e45ad[_0x6aae('0x1e')],function(_0x3b94d7){return{'model':db[_0x3b94d7['model']],'as':_0x3b94d7['as'],'attributes':_0x3b94d7['attributes'],'include':_0x3b94d7[_0x6aae('0x1e')]?_[_0x6aae('0x1d')](_0x3b94d7[_0x6aae('0x1e')],function(_0x14508b){return{'model':db[_0x14508b[_0x6aae('0x1f')]],'as':_0x14508b['as'],'attributes':_0x14508b[_0x6aae('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x6aae('0x20')](function(_0x38be1f){logger[_0x6aae('0xc')](_0x6aae('0x16'),_0x33284c);logger[_0x6aae('0xf')]('GetInterval',_0x33284c,JSON[_0x6aae('0x11')](_0x38be1f));_0x2ef33c(_0x38be1f);})[_0x6aae('0x15')](function(_0x283b54){logger[_0x6aae('0x12')](_0x6aae('0x16'),_0x283b54[_0x6aae('0x13')],_0x33284c);_0xf684cc(_0x120d37[_0x6aae('0x12')](0x1f4,_0x283b54[_0x6aae('0x13')]));});});};exports[_0x6aae('0x21')]=function(_0x57444c){var _0x44cb8c=this;return new Promise(function(_0x578305,_0x5c938a){return db[_0x6aae('0x22')]['find']({'raw':_0x57444c[_0x6aae('0x18')]?_0x57444c['options'][_0x6aae('0x19')]===undefined?!![]:![]:!![],'where':_0x57444c[_0x6aae('0x18')]?_0x57444c[_0x6aae('0x18')][_0x6aae('0x1a')]||null:null,'attributes':_0x57444c[_0x6aae('0x18')]?_0x57444c[_0x6aae('0x18')][_0x6aae('0x1b')]||null:null,'include':_0x57444c['options']?_0x57444c[_0x6aae('0x18')][_0x6aae('0x1e')]?_[_0x6aae('0x1d')](_0x57444c[_0x6aae('0x18')][_0x6aae('0x1e')],function(_0x48566c){return{'model':db[_0x48566c[_0x6aae('0x1f')]],'as':_0x48566c['as'],'attributes':_0x48566c[_0x6aae('0x1b')],'include':_0x48566c['include']?_[_0x6aae('0x1d')](_0x48566c[_0x6aae('0x1e')],function(_0x17a531){return{'model':db[_0x17a531[_0x6aae('0x1f')]],'as':_0x17a531['as'],'attributes':_0x17a531[_0x6aae('0x1b')],'include':_0x17a531[_0x6aae('0x1e')]?_[_0x6aae('0x1d')](_0x17a531[_0x6aae('0x1e')],function(_0x247647){return{'model':db[_0x247647['model']],'as':_0x247647['as'],'attributes':_0x247647[_0x6aae('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x6aae('0x20')](function(_0xff74ab){logger[_0x6aae('0xc')](_0x6aae('0x21'),_0x57444c);logger[_0x6aae('0xf')]('ShowInterval',_0x57444c,JSON[_0x6aae('0x11')](_0xff74ab));_0x578305(_0xff74ab);})[_0x6aae('0x15')](function(_0xaa95c7){logger[_0x6aae('0x12')]('ShowInterval',_0xaa95c7[_0x6aae('0x13')],_0x57444c);_0x5c938a(_0x44cb8c[_0x6aae('0x12')](0x1f4,_0xaa95c7[_0x6aae('0x13')]));});});};