3a01bab319657ff42c8e7231a80d6d8406efa16a
[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 _0x7f70=['request','then','info','stringify','error','code','Variable,\x20%s,\x20%s','message','result','catch','ShowVariable','find','raw','options','where','include','model','attributes','map','debug','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x7f70,0xb4));var _0x07f7=function(_0x352f27,_0x4f565a){_0x352f27=_0x352f27-0x0;var _0x54742a=_0x7f70[_0x352f27];return _0x54742a;};'use strict';var _=require(_0x07f7('0x0'));var util=require('util');var moment=require(_0x07f7('0x1'));var BPromise=require('bluebird');var rs=require(_0x07f7('0x2'));var fs=require('fs');var Redis=require(_0x07f7('0x3'));var db=require(_0x07f7('0x4'))['db'];var utils=require(_0x07f7('0x5'));var logger=require(_0x07f7('0x6'))(_0x07f7('0x7'));var config=require(_0x07f7('0x8'));var jayson=require(_0x07f7('0x9'));var client=jayson[_0x07f7('0xa')][_0x07f7('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x237c4c,_0x452505,_0x1d0202){return new BPromise(function(_0x3cb262,_0x428b7d){return client[_0x07f7('0xc')](_0x237c4c,_0x1d0202)[_0x07f7('0xd')](function(_0x38be1d){logger[_0x07f7('0xe')]('Variable,\x20%s,\x20%s',_0x452505,'request\x20sent');logger['debug']('Variable,\x20%s,\x20%s,\x20%s',_0x452505,'request\x20sent',JSON[_0x07f7('0xf')](_0x38be1d));if(_0x38be1d[_0x07f7('0x10')]){if(_0x38be1d['error'][_0x07f7('0x11')]===0x1f4){logger[_0x07f7('0x10')](_0x07f7('0x12'),_0x452505,_0x38be1d[_0x07f7('0x10')]['message']);return _0x428b7d(_0x38be1d[_0x07f7('0x10')][_0x07f7('0x13')]);}logger[_0x07f7('0x10')]('Variable,\x20%s,\x20%s',_0x452505,_0x38be1d[_0x07f7('0x10')][_0x07f7('0x13')]);return _0x3cb262(_0x38be1d[_0x07f7('0x10')][_0x07f7('0x13')]);}else{logger[_0x07f7('0xe')](_0x07f7('0x12'),_0x452505,'request\x20sent');_0x3cb262(_0x38be1d[_0x07f7('0x14')][_0x07f7('0x13')]);}})[_0x07f7('0x15')](function(_0x482d23){logger[_0x07f7('0x10')]('Variable,\x20%s,\x20%s',_0x452505,_0x482d23);_0x428b7d(_0x482d23);});});}exports[_0x07f7('0x16')]=function(_0x2fc3ae){var _0x5bd746=this;return new Promise(function(_0x32633f,_0x27acfb){return db['Variable'][_0x07f7('0x17')]({'raw':_0x2fc3ae['options']?_0x2fc3ae['options'][_0x07f7('0x18')]===undefined?!![]:![]:!![],'where':_0x2fc3ae[_0x07f7('0x19')]?_0x2fc3ae[_0x07f7('0x19')][_0x07f7('0x1a')]||null:null,'attributes':_0x2fc3ae[_0x07f7('0x19')]?_0x2fc3ae[_0x07f7('0x19')]['attributes']||null:null,'include':_0x2fc3ae[_0x07f7('0x19')]?_0x2fc3ae[_0x07f7('0x19')][_0x07f7('0x1b')]?_['map'](_0x2fc3ae[_0x07f7('0x19')]['include'],function(_0x405bfb){return{'model':db[_0x405bfb[_0x07f7('0x1c')]],'as':_0x405bfb['as'],'attributes':_0x405bfb[_0x07f7('0x1d')],'include':_0x405bfb[_0x07f7('0x1b')]?_['map'](_0x405bfb[_0x07f7('0x1b')],function(_0x23e97a){return{'model':db[_0x23e97a[_0x07f7('0x1c')]],'as':_0x23e97a['as'],'attributes':_0x23e97a[_0x07f7('0x1d')],'include':_0x23e97a[_0x07f7('0x1b')]?_[_0x07f7('0x1e')](_0x23e97a[_0x07f7('0x1b')],function(_0x254e07){return{'model':db[_0x254e07[_0x07f7('0x1c')]],'as':_0x254e07['as'],'attributes':_0x254e07[_0x07f7('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x07f7('0xd')](function(_0x113462){logger[_0x07f7('0xe')](_0x07f7('0x16'),_0x2fc3ae);logger[_0x07f7('0x1f')]('ShowVariable',_0x2fc3ae,JSON[_0x07f7('0xf')](_0x113462));_0x32633f(_0x113462);})[_0x07f7('0x15')](function(_0x5d263a){logger[_0x07f7('0x10')](_0x07f7('0x16'),_0x5d263a[_0x07f7('0x13')],_0x2fc3ae);_0x27acfb(_0x5bd746['error'](0x1f4,_0x5d263a[_0x07f7('0x13')]));});});};