Built motion from commit (unavailable).|2.5.4
[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 _0x48b2=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','Variable,\x20%s,\x20%s','debug','Variable,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','ShowVariable','find','options','raw','where','attributes','include','map','model','util','bluebird','randomstring','ioredis'];(function(_0x4f8063,_0x2336c6){var _0x3c7529=function(_0xfe0913){while(--_0xfe0913){_0x4f8063['push'](_0x4f8063['shift']());}};_0x3c7529(++_0x2336c6);}(_0x48b2,0x1bc));var _0x248b=function(_0x42cd5e,_0x553077){_0x42cd5e=_0x42cd5e-0x0;var _0x3c4097=_0x48b2[_0x42cd5e];return _0x3c4097;};'use strict';var _=require('lodash');var util=require(_0x248b('0x0'));var moment=require('moment');var BPromise=require(_0x248b('0x1'));var rs=require(_0x248b('0x2'));var fs=require('fs');var Redis=require(_0x248b('0x3'));var db=require(_0x248b('0x4'))['db'];var utils=require(_0x248b('0x5'));var logger=require(_0x248b('0x6'))(_0x248b('0x7'));var config=require(_0x248b('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x248b('0x9')][_0x248b('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x427e69,_0x367455,_0x18ad73){return new BPromise(function(_0x5e0def,_0x54222e){return client[_0x248b('0xb')](_0x427e69,_0x18ad73)[_0x248b('0xc')](function(_0x3197d1){logger[_0x248b('0xd')](_0x248b('0xe'),_0x367455,'request\x20sent');logger[_0x248b('0xf')](_0x248b('0x10'),_0x367455,_0x248b('0x11'),JSON['stringify'](_0x3197d1));if(_0x3197d1['error']){if(_0x3197d1[_0x248b('0x12')][_0x248b('0x13')]===0x1f4){logger[_0x248b('0x12')]('Variable,\x20%s,\x20%s',_0x367455,_0x3197d1[_0x248b('0x12')][_0x248b('0x14')]);return _0x54222e(_0x3197d1[_0x248b('0x12')]['message']);}logger[_0x248b('0x12')](_0x248b('0xe'),_0x367455,_0x3197d1[_0x248b('0x12')][_0x248b('0x14')]);return _0x5e0def(_0x3197d1['error'][_0x248b('0x14')]);}else{logger['info'](_0x248b('0xe'),_0x367455,_0x248b('0x11'));_0x5e0def(_0x3197d1[_0x248b('0x15')][_0x248b('0x14')]);}})[_0x248b('0x16')](function(_0x2609fc){logger[_0x248b('0x12')]('Variable,\x20%s,\x20%s',_0x367455,_0x2609fc);_0x54222e(_0x2609fc);});});}exports[_0x248b('0x17')]=function(_0x2e884e){var _0x36b824=this;return new Promise(function(_0x227aad,_0x9893fe){return db['Variable'][_0x248b('0x18')]({'raw':_0x2e884e['options']?_0x2e884e[_0x248b('0x19')][_0x248b('0x1a')]===undefined?!![]:![]:!![],'where':_0x2e884e['options']?_0x2e884e[_0x248b('0x19')][_0x248b('0x1b')]||null:null,'attributes':_0x2e884e[_0x248b('0x19')]?_0x2e884e[_0x248b('0x19')][_0x248b('0x1c')]||null:null,'include':_0x2e884e[_0x248b('0x19')]?_0x2e884e[_0x248b('0x19')][_0x248b('0x1d')]?_[_0x248b('0x1e')](_0x2e884e[_0x248b('0x19')][_0x248b('0x1d')],function(_0x1234d7){return{'model':db[_0x1234d7[_0x248b('0x1f')]],'as':_0x1234d7['as'],'attributes':_0x1234d7[_0x248b('0x1c')],'include':_0x1234d7[_0x248b('0x1d')]?_['map'](_0x1234d7[_0x248b('0x1d')],function(_0x1a3a0a){return{'model':db[_0x1a3a0a['model']],'as':_0x1a3a0a['as'],'attributes':_0x1a3a0a[_0x248b('0x1c')],'include':_0x1a3a0a[_0x248b('0x1d')]?_[_0x248b('0x1e')](_0x1a3a0a['include'],function(_0x13670e){return{'model':db[_0x13670e[_0x248b('0x1f')]],'as':_0x13670e['as'],'attributes':_0x13670e[_0x248b('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x248b('0xc')](function(_0x15b32a){logger['info'](_0x248b('0x17'),_0x2e884e);logger[_0x248b('0xf')](_0x248b('0x17'),_0x2e884e,JSON['stringify'](_0x15b32a));_0x227aad(_0x15b32a);})[_0x248b('0x16')](function(_0x1f5624){logger[_0x248b('0x12')]('ShowVariable',_0x1f5624['message'],_0x2e884e);_0x9893fe(_0x36b824[_0x248b('0x12')](0x1f4,_0x1f5624[_0x248b('0x14')]));});});};