78400f255345e9423d287381c675dd45f5762884
[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 _0x9982=['http','request','then','debug','request\x20sent','stringify','error','code','Variable,\x20%s,\x20%s','message','info','result','catch','ShowVariable','Variable','find','options','where','attributes','map','include','model','lodash','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x31f405,_0x52a7a0){var _0x595af8=function(_0x53905b){while(--_0x53905b){_0x31f405['push'](_0x31f405['shift']());}};_0x595af8(++_0x52a7a0);}(_0x9982,0xb6));var _0x2998=function(_0x5ef582,_0x4d6bdd){_0x5ef582=_0x5ef582-0x0;var _0x40377e=_0x9982[_0x5ef582];return _0x40377e;};'use strict';var _=require(_0x2998('0x0'));var util=require('util');var moment=require(_0x2998('0x1'));var BPromise=require(_0x2998('0x2'));var rs=require(_0x2998('0x3'));var fs=require('fs');var Redis=require(_0x2998('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x2998('0x5'))(_0x2998('0x6'));var config=require(_0x2998('0x7'));var jayson=require(_0x2998('0x8'));var client=jayson[_0x2998('0x9')][_0x2998('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x49f270,_0x3b41b0,_0x261063){return new BPromise(function(_0x3065ce,_0xc6824f){return client[_0x2998('0xb')](_0x49f270,_0x261063)[_0x2998('0xc')](function(_0x529af6){logger['info']('Variable,\x20%s,\x20%s',_0x3b41b0,'request\x20sent');logger[_0x2998('0xd')]('Variable,\x20%s,\x20%s,\x20%s',_0x3b41b0,_0x2998('0xe'),JSON[_0x2998('0xf')](_0x529af6));if(_0x529af6[_0x2998('0x10')]){if(_0x529af6['error'][_0x2998('0x11')]===0x1f4){logger[_0x2998('0x10')](_0x2998('0x12'),_0x3b41b0,_0x529af6[_0x2998('0x10')][_0x2998('0x13')]);return _0xc6824f(_0x529af6['error'][_0x2998('0x13')]);}logger[_0x2998('0x10')](_0x2998('0x12'),_0x3b41b0,_0x529af6[_0x2998('0x10')][_0x2998('0x13')]);return _0x3065ce(_0x529af6['error']['message']);}else{logger[_0x2998('0x14')](_0x2998('0x12'),_0x3b41b0,_0x2998('0xe'));_0x3065ce(_0x529af6[_0x2998('0x15')][_0x2998('0x13')]);}})[_0x2998('0x16')](function(_0x19efb9){logger[_0x2998('0x10')](_0x2998('0x12'),_0x3b41b0,_0x19efb9);_0xc6824f(_0x19efb9);});});}exports[_0x2998('0x17')]=function(_0x3db0a3){var _0x36a5ea=this;return new Promise(function(_0x47d23e,_0x4a27b9){return db[_0x2998('0x18')][_0x2998('0x19')]({'raw':_0x3db0a3[_0x2998('0x1a')]?_0x3db0a3[_0x2998('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x3db0a3[_0x2998('0x1a')]?_0x3db0a3['options'][_0x2998('0x1b')]||null:null,'attributes':_0x3db0a3[_0x2998('0x1a')]?_0x3db0a3[_0x2998('0x1a')][_0x2998('0x1c')]||null:null,'include':_0x3db0a3[_0x2998('0x1a')]?_0x3db0a3['options']['include']?_[_0x2998('0x1d')](_0x3db0a3[_0x2998('0x1a')][_0x2998('0x1e')],function(_0x5f0b51){return{'model':db[_0x5f0b51['model']],'as':_0x5f0b51['as'],'attributes':_0x5f0b51[_0x2998('0x1c')],'include':_0x5f0b51['include']?_[_0x2998('0x1d')](_0x5f0b51[_0x2998('0x1e')],function(_0x11e41c){return{'model':db[_0x11e41c['model']],'as':_0x11e41c['as'],'attributes':_0x11e41c[_0x2998('0x1c')],'include':_0x11e41c[_0x2998('0x1e')]?_[_0x2998('0x1d')](_0x11e41c[_0x2998('0x1e')],function(_0x3d3823){return{'model':db[_0x3d3823[_0x2998('0x1f')]],'as':_0x3d3823['as'],'attributes':_0x3d3823[_0x2998('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x2998('0xc')](function(_0x534ab4){logger[_0x2998('0x14')]('ShowVariable',_0x3db0a3);logger[_0x2998('0xd')]('ShowVariable',_0x3db0a3,JSON[_0x2998('0xf')](_0x534ab4));_0x47d23e(_0x534ab4);})[_0x2998('0x16')](function(_0x3bb9db){logger['error'](_0x2998('0x17'),_0x3bb9db[_0x2998('0x13')],_0x3db0a3);_0x4a27b9(_0x36a5ea[_0x2998('0x10')](0x1f4,_0x3bb9db[_0x2998('0x13')]));});});};