Built motion from commit 67e5df37.|2.0.66
[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 _0x9cfc=['find','options','raw','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','Variable,\x20%s,\x20%s,\x20%s','stringify','error','Variable,\x20%s,\x20%s','message','info','catch','ShowVariable','Variable'];(function(_0x7d0ecc,_0x165f3c){var _0x17a265=function(_0x37ad01){while(--_0x37ad01){_0x7d0ecc['push'](_0x7d0ecc['shift']());}};_0x17a265(++_0x165f3c);}(_0x9cfc,0x128));var _0xc9cf=function(_0x53ddb8,_0x5b9723){_0x53ddb8=_0x53ddb8-0x0;var _0x4387a1=_0x9cfc[_0x53ddb8];return _0x4387a1;};'use strict';var _=require(_0xc9cf('0x0'));var util=require(_0xc9cf('0x1'));var moment=require(_0xc9cf('0x2'));var BPromise=require(_0xc9cf('0x3'));var rs=require(_0xc9cf('0x4'));var fs=require('fs');var db=require(_0xc9cf('0x5'))['db'];var utils=require(_0xc9cf('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xc9cf('0x7'));var jayson=require(_0xc9cf('0x8'));var client=jayson[_0xc9cf('0x9')][_0xc9cf('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5e9dba,_0x252dcf,_0x4d66ba){return new BPromise(function(_0x1b33bc,_0x40efba){return client[_0xc9cf('0xb')](_0x5e9dba,_0x4d66ba)[_0xc9cf('0xc')](function(_0x32aaaf){logger['info']('Variable,\x20%s,\x20%s',_0x252dcf,_0xc9cf('0xd'));logger[_0xc9cf('0xe')](_0xc9cf('0xf'),_0x252dcf,_0xc9cf('0xd'),JSON[_0xc9cf('0x10')](_0x32aaaf));if(_0x32aaaf[_0xc9cf('0x11')]){if(_0x32aaaf['error']['code']===0x1f4){logger['error'](_0xc9cf('0x12'),_0x252dcf,_0x32aaaf[_0xc9cf('0x11')][_0xc9cf('0x13')]);return _0x40efba(_0x32aaaf[_0xc9cf('0x11')][_0xc9cf('0x13')]);}logger['error'](_0xc9cf('0x12'),_0x252dcf,_0x32aaaf[_0xc9cf('0x11')]['message']);return _0x1b33bc(_0x32aaaf['error']['message']);}else{logger[_0xc9cf('0x14')](_0xc9cf('0x12'),_0x252dcf,_0xc9cf('0xd'));_0x1b33bc(_0x32aaaf['result'][_0xc9cf('0x13')]);}})[_0xc9cf('0x15')](function(_0x4e2d7d){logger[_0xc9cf('0x11')](_0xc9cf('0x12'),_0x252dcf,_0x4e2d7d);_0x40efba(_0x4e2d7d);});});}exports[_0xc9cf('0x16')]=function(_0x3c351d){var _0x427839=this;return new Promise(function(_0x3e316d,_0x347e36){return db[_0xc9cf('0x17')][_0xc9cf('0x18')]({'raw':_0x3c351d['options']?_0x3c351d[_0xc9cf('0x19')][_0xc9cf('0x1a')]===undefined?!![]:![]:!![],'where':_0x3c351d['options']?_0x3c351d[_0xc9cf('0x19')][_0xc9cf('0x1b')]||null:null,'attributes':_0x3c351d[_0xc9cf('0x19')]?_0x3c351d[_0xc9cf('0x19')][_0xc9cf('0x1c')]||null:null,'include':_0x3c351d[_0xc9cf('0x19')]?_0x3c351d[_0xc9cf('0x19')][_0xc9cf('0x1d')]?_[_0xc9cf('0x1e')](_0x3c351d['options'][_0xc9cf('0x1d')],function(_0x46d333){return{'model':db[_0x46d333[_0xc9cf('0x1f')]],'as':_0x46d333['as'],'attributes':_0x46d333[_0xc9cf('0x1c')],'include':_0x46d333[_0xc9cf('0x1d')]?_[_0xc9cf('0x1e')](_0x46d333[_0xc9cf('0x1d')],function(_0x2e3358){return{'model':db[_0x2e3358[_0xc9cf('0x1f')]],'as':_0x2e3358['as'],'attributes':_0x2e3358[_0xc9cf('0x1c')],'include':_0x2e3358[_0xc9cf('0x1d')]?_[_0xc9cf('0x1e')](_0x2e3358[_0xc9cf('0x1d')],function(_0x57696c){return{'model':db[_0x57696c[_0xc9cf('0x1f')]],'as':_0x57696c['as'],'attributes':_0x57696c[_0xc9cf('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xc9cf('0xc')](function(_0x1d6f44){logger[_0xc9cf('0x14')](_0xc9cf('0x16'),_0x3c351d);logger[_0xc9cf('0xe')](_0xc9cf('0x16'),_0x3c351d,JSON[_0xc9cf('0x10')](_0x1d6f44));_0x3e316d(_0x1d6f44);})[_0xc9cf('0x15')](function(_0x415f92){logger['error'](_0xc9cf('0x16'),_0x415f92['message'],_0x3c351d);_0x347e36(_0x427839['error'](0x1f4,_0x415f92[_0xc9cf('0x13')]));});});};