Built motion from commit (unavailable).|2.5.21
[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 _0x2c71=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','http','request','info','Variable,\x20%s,\x20%s','request\x20sent','debug','Variable,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','ShowVariable','Variable','find','options','raw','where','include','map','attributes','model','then','util','moment'];(function(_0xc4001c,_0x1bf8f0){var _0x49f7bc=function(_0x1059b8){while(--_0x1059b8){_0xc4001c['push'](_0xc4001c['shift']());}};_0x49f7bc(++_0x1bf8f0);}(_0x2c71,0x18a));var _0x12c7=function(_0x25d6ad,_0x402756){_0x25d6ad=_0x25d6ad-0x0;var _0xb51391=_0x2c71[_0x25d6ad];return _0xb51391;};'use strict';var _=require('lodash');var util=require(_0x12c7('0x0'));var moment=require(_0x12c7('0x1'));var BPromise=require(_0x12c7('0x2'));var rs=require(_0x12c7('0x3'));var fs=require('fs');var Redis=require(_0x12c7('0x4'));var db=require(_0x12c7('0x5'))['db'];var utils=require(_0x12c7('0x6'));var logger=require(_0x12c7('0x7'))(_0x12c7('0x8'));var config=require(_0x12c7('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x12c7('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x480f3b,_0x43487e,_0x3685b2){return new BPromise(function(_0x3bb169,_0x20d864){return client[_0x12c7('0xb')](_0x480f3b,_0x3685b2)['then'](function(_0x463369){logger[_0x12c7('0xc')](_0x12c7('0xd'),_0x43487e,_0x12c7('0xe'));logger[_0x12c7('0xf')](_0x12c7('0x10'),_0x43487e,'request\x20sent',JSON['stringify'](_0x463369));if(_0x463369[_0x12c7('0x11')]){if(_0x463369[_0x12c7('0x11')][_0x12c7('0x12')]===0x1f4){logger[_0x12c7('0x11')](_0x12c7('0xd'),_0x43487e,_0x463369[_0x12c7('0x11')][_0x12c7('0x13')]);return _0x20d864(_0x463369[_0x12c7('0x11')][_0x12c7('0x13')]);}logger[_0x12c7('0x11')]('Variable,\x20%s,\x20%s',_0x43487e,_0x463369[_0x12c7('0x11')][_0x12c7('0x13')]);return _0x3bb169(_0x463369[_0x12c7('0x11')][_0x12c7('0x13')]);}else{logger[_0x12c7('0xc')](_0x12c7('0xd'),_0x43487e,_0x12c7('0xe'));_0x3bb169(_0x463369[_0x12c7('0x14')][_0x12c7('0x13')]);}})[_0x12c7('0x15')](function(_0x9e9cf2){logger['error']('Variable,\x20%s,\x20%s',_0x43487e,_0x9e9cf2);_0x20d864(_0x9e9cf2);});});}exports[_0x12c7('0x16')]=function(_0x52b8f2){var _0x57996f=this;return new Promise(function(_0x3ccd94,_0x58cabc){return db[_0x12c7('0x17')][_0x12c7('0x18')]({'raw':_0x52b8f2[_0x12c7('0x19')]?_0x52b8f2[_0x12c7('0x19')][_0x12c7('0x1a')]===undefined?!![]:![]:!![],'where':_0x52b8f2[_0x12c7('0x19')]?_0x52b8f2[_0x12c7('0x19')][_0x12c7('0x1b')]||null:null,'attributes':_0x52b8f2['options']?_0x52b8f2[_0x12c7('0x19')]['attributes']||null:null,'include':_0x52b8f2[_0x12c7('0x19')]?_0x52b8f2['options'][_0x12c7('0x1c')]?_[_0x12c7('0x1d')](_0x52b8f2[_0x12c7('0x19')]['include'],function(_0x1823a8){return{'model':db[_0x1823a8['model']],'as':_0x1823a8['as'],'attributes':_0x1823a8[_0x12c7('0x1e')],'include':_0x1823a8['include']?_[_0x12c7('0x1d')](_0x1823a8[_0x12c7('0x1c')],function(_0x530971){return{'model':db[_0x530971[_0x12c7('0x1f')]],'as':_0x530971['as'],'attributes':_0x530971[_0x12c7('0x1e')],'include':_0x530971[_0x12c7('0x1c')]?_['map'](_0x530971[_0x12c7('0x1c')],function(_0x557444){return{'model':db[_0x557444[_0x12c7('0x1f')]],'as':_0x557444['as'],'attributes':_0x557444[_0x12c7('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x12c7('0x20')](function(_0x4609b4){logger[_0x12c7('0xc')](_0x12c7('0x16'),_0x52b8f2);logger[_0x12c7('0xf')]('ShowVariable',_0x52b8f2,JSON['stringify'](_0x4609b4));_0x3ccd94(_0x4609b4);})[_0x12c7('0x15')](function(_0x28995f){logger[_0x12c7('0x11')](_0x12c7('0x16'),_0x28995f[_0x12c7('0x13')],_0x52b8f2);_0x58cabc(_0x57996f[_0x12c7('0x11')](0x1f4,_0x28995f[_0x12c7('0x13')]));});});};