Built motion from commit (unavailable).|2.5.8
[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 _0x7b93=['request\x20sent','debug','Interval,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetInterval','Interval','findAll','options','where','attributes','include','map','model','find','raw','ShowInterval','lodash','util','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','Interval,\x20%s,\x20%s'];(function(_0xbb9dbf,_0x5dafa4){var _0x30223c=function(_0xaa9ca){while(--_0xaa9ca){_0xbb9dbf['push'](_0xbb9dbf['shift']());}};_0x30223c(++_0x5dafa4);}(_0x7b93,0x1dc));var _0x37b9=function(_0x4bf5f2,_0x48040d){_0x4bf5f2=_0x4bf5f2-0x0;var _0x9d49ee=_0x7b93[_0x4bf5f2];return _0x9d49ee;};'use strict';var _=require(_0x37b9('0x0'));var util=require(_0x37b9('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x37b9('0x2'));var fs=require('fs');var Redis=require(_0x37b9('0x3'));var db=require(_0x37b9('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x37b9('0x5'))(_0x37b9('0x6'));var config=require(_0x37b9('0x7'));var jayson=require(_0x37b9('0x8'));var client=jayson[_0x37b9('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3418ad,_0x1d0623,_0x369d45){return new BPromise(function(_0x3c4221,_0x3f308a){return client[_0x37b9('0xa')](_0x3418ad,_0x369d45)[_0x37b9('0xb')](function(_0x1a5ed4){logger[_0x37b9('0xc')](_0x37b9('0xd'),_0x1d0623,_0x37b9('0xe'));logger[_0x37b9('0xf')](_0x37b9('0x10'),_0x1d0623,_0x37b9('0xe'),JSON[_0x37b9('0x11')](_0x1a5ed4));if(_0x1a5ed4[_0x37b9('0x12')]){if(_0x1a5ed4['error'][_0x37b9('0x13')]===0x1f4){logger[_0x37b9('0x12')](_0x37b9('0xd'),_0x1d0623,_0x1a5ed4[_0x37b9('0x12')][_0x37b9('0x14')]);return _0x3f308a(_0x1a5ed4[_0x37b9('0x12')][_0x37b9('0x14')]);}logger[_0x37b9('0x12')](_0x37b9('0xd'),_0x1d0623,_0x1a5ed4[_0x37b9('0x12')][_0x37b9('0x14')]);return _0x3c4221(_0x1a5ed4['error'][_0x37b9('0x14')]);}else{logger['info'](_0x37b9('0xd'),_0x1d0623,_0x37b9('0xe'));_0x3c4221(_0x1a5ed4[_0x37b9('0x15')][_0x37b9('0x14')]);}})[_0x37b9('0x16')](function(_0x50ba54){logger['error'](_0x37b9('0xd'),_0x1d0623,_0x50ba54);_0x3f308a(_0x50ba54);});});}exports[_0x37b9('0x17')]=function(_0x24d910){var _0x114663=this;return new Promise(function(_0x51153f,_0x5ec2cc){return db[_0x37b9('0x18')][_0x37b9('0x19')]({'raw':_0x24d910['options']?_0x24d910[_0x37b9('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x24d910[_0x37b9('0x1a')]?_0x24d910[_0x37b9('0x1a')][_0x37b9('0x1b')]||null:null,'attributes':_0x24d910['options']?_0x24d910[_0x37b9('0x1a')][_0x37b9('0x1c')]||null:null,'limit':_0x24d910[_0x37b9('0x1a')]?_0x24d910[_0x37b9('0x1a')]['limit']||null:null,'include':_0x24d910['options']?_0x24d910[_0x37b9('0x1a')][_0x37b9('0x1d')]?_[_0x37b9('0x1e')](_0x24d910[_0x37b9('0x1a')]['include'],function(_0x5a76f5){return{'model':db[_0x5a76f5[_0x37b9('0x1f')]],'as':_0x5a76f5['as'],'attributes':_0x5a76f5[_0x37b9('0x1c')],'include':_0x5a76f5['include']?_[_0x37b9('0x1e')](_0x5a76f5[_0x37b9('0x1d')],function(_0x420da6){return{'model':db[_0x420da6[_0x37b9('0x1f')]],'as':_0x420da6['as'],'attributes':_0x420da6['attributes'],'include':_0x420da6['include']?_[_0x37b9('0x1e')](_0x420da6[_0x37b9('0x1d')],function(_0xf03d5){return{'model':db[_0xf03d5[_0x37b9('0x1f')]],'as':_0xf03d5['as'],'attributes':_0xf03d5[_0x37b9('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x37b9('0xb')](function(_0x34a108){logger['info'](_0x37b9('0x17'),_0x24d910);logger['debug'](_0x37b9('0x17'),_0x24d910,JSON[_0x37b9('0x11')](_0x34a108));_0x51153f(_0x34a108);})[_0x37b9('0x16')](function(_0x5dbbc0){logger[_0x37b9('0x12')](_0x37b9('0x17'),_0x5dbbc0['message'],_0x24d910);_0x5ec2cc(_0x114663[_0x37b9('0x12')](0x1f4,_0x5dbbc0[_0x37b9('0x14')]));});});};exports['ShowInterval']=function(_0x544dcb){var _0x291120=this;return new Promise(function(_0x2779f2,_0x1b0c74){return db[_0x37b9('0x18')][_0x37b9('0x20')]({'raw':_0x544dcb[_0x37b9('0x1a')]?_0x544dcb['options'][_0x37b9('0x21')]===undefined?!![]:![]:!![],'where':_0x544dcb[_0x37b9('0x1a')]?_0x544dcb[_0x37b9('0x1a')][_0x37b9('0x1b')]||null:null,'attributes':_0x544dcb['options']?_0x544dcb[_0x37b9('0x1a')][_0x37b9('0x1c')]||null:null,'include':_0x544dcb[_0x37b9('0x1a')]?_0x544dcb[_0x37b9('0x1a')][_0x37b9('0x1d')]?_[_0x37b9('0x1e')](_0x544dcb[_0x37b9('0x1a')]['include'],function(_0x1a1a74){return{'model':db[_0x1a1a74[_0x37b9('0x1f')]],'as':_0x1a1a74['as'],'attributes':_0x1a1a74[_0x37b9('0x1c')],'include':_0x1a1a74[_0x37b9('0x1d')]?_['map'](_0x1a1a74['include'],function(_0x2573ad){return{'model':db[_0x2573ad[_0x37b9('0x1f')]],'as':_0x2573ad['as'],'attributes':_0x2573ad['attributes'],'include':_0x2573ad[_0x37b9('0x1d')]?_[_0x37b9('0x1e')](_0x2573ad[_0x37b9('0x1d')],function(_0x4e5f0c){return{'model':db[_0x4e5f0c['model']],'as':_0x4e5f0c['as'],'attributes':_0x4e5f0c[_0x37b9('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1a424a){logger[_0x37b9('0xc')](_0x37b9('0x22'),_0x544dcb);logger[_0x37b9('0xf')](_0x37b9('0x22'),_0x544dcb,JSON[_0x37b9('0x11')](_0x1a424a));_0x2779f2(_0x1a424a);})[_0x37b9('0x16')](function(_0xc0ae3b){logger['error'](_0x37b9('0x22'),_0xc0ae3b[_0x37b9('0x14')],_0x544dcb);_0x1b0c74(_0x291120[_0x37b9('0x12')](0x1f4,_0xc0ae3b['message']));});});};