Built motion from commit (unavailable).|2.3.94
[motion2.git] / server / api / variable / variable.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 _0x3ed6=['info','stringify','error','code','Variable,\x20%s,\x20%s','message','request\x20sent','result','catch','Variable','find','options','raw','attributes','include','map','model','ShowVariable','debug','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then'];(function(_0x50b1e4,_0x3057ce){var _0x12d199=function(_0x35ada2){while(--_0x35ada2){_0x50b1e4['push'](_0x50b1e4['shift']());}};_0x12d199(++_0x3057ce);}(_0x3ed6,0x8f));var _0x63ed=function(_0x19cd7d,_0x216c4a){_0x19cd7d=_0x19cd7d-0x0;var _0x3f084b=_0x3ed6[_0x19cd7d];return _0x3f084b;};'use strict';var _=require(_0x63ed('0x0'));var util=require(_0x63ed('0x1'));var moment=require('moment');var BPromise=require(_0x63ed('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x63ed('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x63ed('0x4'));var logger=require(_0x63ed('0x5'))(_0x63ed('0x6'));var config=require(_0x63ed('0x7'));var jayson=require(_0x63ed('0x8'));var client=jayson[_0x63ed('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4980bd,_0x11d184,_0x5d4b03){return new BPromise(function(_0x471f2d,_0x3d8272){return client[_0x63ed('0xa')](_0x4980bd,_0x5d4b03)[_0x63ed('0xb')](function(_0x39bdc1){logger[_0x63ed('0xc')]('Variable,\x20%s,\x20%s',_0x11d184,'request\x20sent');logger['debug']('Variable,\x20%s,\x20%s,\x20%s',_0x11d184,'request\x20sent',JSON[_0x63ed('0xd')](_0x39bdc1));if(_0x39bdc1['error']){if(_0x39bdc1[_0x63ed('0xe')][_0x63ed('0xf')]===0x1f4){logger[_0x63ed('0xe')](_0x63ed('0x10'),_0x11d184,_0x39bdc1[_0x63ed('0xe')][_0x63ed('0x11')]);return _0x3d8272(_0x39bdc1[_0x63ed('0xe')]['message']);}logger[_0x63ed('0xe')](_0x63ed('0x10'),_0x11d184,_0x39bdc1[_0x63ed('0xe')][_0x63ed('0x11')]);return _0x471f2d(_0x39bdc1['error'][_0x63ed('0x11')]);}else{logger[_0x63ed('0xc')](_0x63ed('0x10'),_0x11d184,_0x63ed('0x12'));_0x471f2d(_0x39bdc1[_0x63ed('0x13')][_0x63ed('0x11')]);}})[_0x63ed('0x14')](function(_0x53ad3a){logger[_0x63ed('0xe')]('Variable,\x20%s,\x20%s',_0x11d184,_0x53ad3a);_0x3d8272(_0x53ad3a);});});}exports['ShowVariable']=function(_0x43e9c8){var _0x2ff668=this;return new Promise(function(_0x5bc5c8,_0x2e7a05){return db[_0x63ed('0x15')][_0x63ed('0x16')]({'raw':_0x43e9c8[_0x63ed('0x17')]?_0x43e9c8[_0x63ed('0x17')][_0x63ed('0x18')]===undefined?!![]:![]:!![],'where':_0x43e9c8['options']?_0x43e9c8[_0x63ed('0x17')]['where']||null:null,'attributes':_0x43e9c8[_0x63ed('0x17')]?_0x43e9c8[_0x63ed('0x17')][_0x63ed('0x19')]||null:null,'include':_0x43e9c8[_0x63ed('0x17')]?_0x43e9c8['options'][_0x63ed('0x1a')]?_['map'](_0x43e9c8[_0x63ed('0x17')][_0x63ed('0x1a')],function(_0x41ba69){return{'model':db[_0x41ba69['model']],'as':_0x41ba69['as'],'attributes':_0x41ba69['attributes'],'include':_0x41ba69[_0x63ed('0x1a')]?_[_0x63ed('0x1b')](_0x41ba69['include'],function(_0x511f60){return{'model':db[_0x511f60[_0x63ed('0x1c')]],'as':_0x511f60['as'],'attributes':_0x511f60['attributes'],'include':_0x511f60[_0x63ed('0x1a')]?_['map'](_0x511f60[_0x63ed('0x1a')],function(_0xa1dd4){return{'model':db[_0xa1dd4[_0x63ed('0x1c')]],'as':_0xa1dd4['as'],'attributes':_0xa1dd4['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2aebed){logger['info'](_0x63ed('0x1d'),_0x43e9c8);logger[_0x63ed('0x1e')](_0x63ed('0x1d'),_0x43e9c8,JSON[_0x63ed('0xd')](_0x2aebed));_0x5bc5c8(_0x2aebed);})[_0x63ed('0x14')](function(_0x21bb1c){logger[_0x63ed('0xe')](_0x63ed('0x1d'),_0x21bb1c[_0x63ed('0x11')],_0x43e9c8);_0x2e7a05(_0x2ff668[_0x63ed('0xe')](0x1f4,_0x21bb1c[_0x63ed('0x11')]));});});};