d09e388537a75167f08d7c0e587d4b9bb59a3a4e
[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 _0x7881=['message','result','catch','ShowVariable','options','where','attributes','include','model','map','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','request','info','Variable,\x20%s,\x20%s','request\x20sent','debug','Variable,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x517c0c,_0x16ec8e){var _0x546f36=function(_0x240763){while(--_0x240763){_0x517c0c['push'](_0x517c0c['shift']());}};_0x546f36(++_0x16ec8e);}(_0x7881,0xa0));var _0x1788=function(_0x3010f4,_0x19d46d){_0x3010f4=_0x3010f4-0x0;var _0x5a468e=_0x7881[_0x3010f4];return _0x5a468e;};'use strict';var _=require(_0x1788('0x0'));var util=require(_0x1788('0x1'));var moment=require('moment');var BPromise=require(_0x1788('0x2'));var rs=require(_0x1788('0x3'));var fs=require('fs');var Redis=require(_0x1788('0x4'));var db=require(_0x1788('0x5'))['db'];var utils=require(_0x1788('0x6'));var logger=require(_0x1788('0x7'))(_0x1788('0x8'));var config=require(_0x1788('0x9'));var jayson=require(_0x1788('0xa'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x116267,_0x34240b,_0x4f594e){return new BPromise(function(_0x2e144f,_0x2cd1b5){return client[_0x1788('0xb')](_0x116267,_0x4f594e)['then'](function(_0x1d9bd8){logger[_0x1788('0xc')](_0x1788('0xd'),_0x34240b,_0x1788('0xe'));logger[_0x1788('0xf')](_0x1788('0x10'),_0x34240b,_0x1788('0xe'),JSON[_0x1788('0x11')](_0x1d9bd8));if(_0x1d9bd8[_0x1788('0x12')]){if(_0x1d9bd8[_0x1788('0x12')][_0x1788('0x13')]===0x1f4){logger['error'](_0x1788('0xd'),_0x34240b,_0x1d9bd8['error'][_0x1788('0x14')]);return _0x2cd1b5(_0x1d9bd8[_0x1788('0x12')]['message']);}logger[_0x1788('0x12')]('Variable,\x20%s,\x20%s',_0x34240b,_0x1d9bd8['error'][_0x1788('0x14')]);return _0x2e144f(_0x1d9bd8[_0x1788('0x12')][_0x1788('0x14')]);}else{logger[_0x1788('0xc')](_0x1788('0xd'),_0x34240b,_0x1788('0xe'));_0x2e144f(_0x1d9bd8[_0x1788('0x15')][_0x1788('0x14')]);}})[_0x1788('0x16')](function(_0x13ce5f){logger[_0x1788('0x12')](_0x1788('0xd'),_0x34240b,_0x13ce5f);_0x2cd1b5(_0x13ce5f);});});}exports[_0x1788('0x17')]=function(_0x27f96b){var _0x256229=this;return new Promise(function(_0x378dc8,_0x44acb3){return db['Variable']['find']({'raw':_0x27f96b[_0x1788('0x18')]?_0x27f96b[_0x1788('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x27f96b[_0x1788('0x18')]?_0x27f96b[_0x1788('0x18')][_0x1788('0x19')]||null:null,'attributes':_0x27f96b[_0x1788('0x18')]?_0x27f96b[_0x1788('0x18')][_0x1788('0x1a')]||null:null,'include':_0x27f96b['options']?_0x27f96b[_0x1788('0x18')][_0x1788('0x1b')]?_['map'](_0x27f96b[_0x1788('0x18')]['include'],function(_0x4f338b){return{'model':db[_0x4f338b[_0x1788('0x1c')]],'as':_0x4f338b['as'],'attributes':_0x4f338b[_0x1788('0x1a')],'include':_0x4f338b[_0x1788('0x1b')]?_[_0x1788('0x1d')](_0x4f338b['include'],function(_0x445a84){return{'model':db[_0x445a84[_0x1788('0x1c')]],'as':_0x445a84['as'],'attributes':_0x445a84[_0x1788('0x1a')],'include':_0x445a84[_0x1788('0x1b')]?_[_0x1788('0x1d')](_0x445a84['include'],function(_0x214590){return{'model':db[_0x214590[_0x1788('0x1c')]],'as':_0x214590['as'],'attributes':_0x214590['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2e9f64){logger[_0x1788('0xc')](_0x1788('0x17'),_0x27f96b);logger[_0x1788('0xf')](_0x1788('0x17'),_0x27f96b,JSON[_0x1788('0x11')](_0x2e9f64));_0x378dc8(_0x2e9f64);})['catch'](function(_0x5ad5e7){logger[_0x1788('0x12')]('ShowVariable',_0x5ad5e7[_0x1788('0x14')],_0x27f96b);_0x44acb3(_0x256229[_0x1788('0x12')](0x1f4,_0x5ad5e7[_0x1788('0x14')]));});});};