Built motion from commit (unavailable).|2.4.13
[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 _0x0076=['error','code','message','result','ShowVariable','find','options','raw','where','attributes','map','include','model','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Variable,\x20%s,\x20%s','debug','Variable,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x1ed4de,_0x43d1c2){var _0x3e9b85=function(_0x56b287){while(--_0x56b287){_0x1ed4de['push'](_0x1ed4de['shift']());}};_0x3e9b85(++_0x43d1c2);}(_0x0076,0x1ea));var _0x6007=function(_0x4b73a2,_0x40b5fe){_0x4b73a2=_0x4b73a2-0x0;var _0x383c66=_0x0076[_0x4b73a2];return _0x383c66;};'use strict';var _=require(_0x6007('0x0'));var util=require(_0x6007('0x1'));var moment=require(_0x6007('0x2'));var BPromise=require('bluebird');var rs=require(_0x6007('0x3'));var fs=require('fs');var Redis=require(_0x6007('0x4'));var db=require(_0x6007('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x6007('0x6'))(_0x6007('0x7'));var config=require(_0x6007('0x8'));var jayson=require(_0x6007('0x9'));var client=jayson[_0x6007('0xa')][_0x6007('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3e3590,_0x37a1f8,_0x2026f5){return new BPromise(function(_0x35e5b0,_0x391596){return client[_0x6007('0xc')](_0x3e3590,_0x2026f5)[_0x6007('0xd')](function(_0xa7f59d){logger[_0x6007('0xe')](_0x6007('0xf'),_0x37a1f8,'request\x20sent');logger[_0x6007('0x10')](_0x6007('0x11'),_0x37a1f8,_0x6007('0x12'),JSON[_0x6007('0x13')](_0xa7f59d));if(_0xa7f59d[_0x6007('0x14')]){if(_0xa7f59d[_0x6007('0x14')][_0x6007('0x15')]===0x1f4){logger[_0x6007('0x14')](_0x6007('0xf'),_0x37a1f8,_0xa7f59d[_0x6007('0x14')]['message']);return _0x391596(_0xa7f59d['error'][_0x6007('0x16')]);}logger[_0x6007('0x14')]('Variable,\x20%s,\x20%s',_0x37a1f8,_0xa7f59d[_0x6007('0x14')][_0x6007('0x16')]);return _0x35e5b0(_0xa7f59d['error'][_0x6007('0x16')]);}else{logger[_0x6007('0xe')](_0x6007('0xf'),_0x37a1f8,_0x6007('0x12'));_0x35e5b0(_0xa7f59d[_0x6007('0x17')]['message']);}})['catch'](function(_0x59808d){logger[_0x6007('0x14')](_0x6007('0xf'),_0x37a1f8,_0x59808d);_0x391596(_0x59808d);});});}exports[_0x6007('0x18')]=function(_0x10dc13){var _0x4d0ea1=this;return new Promise(function(_0x4cf4ff,_0x355566){return db['Variable'][_0x6007('0x19')]({'raw':_0x10dc13[_0x6007('0x1a')]?_0x10dc13[_0x6007('0x1a')][_0x6007('0x1b')]===undefined?!![]:![]:!![],'where':_0x10dc13[_0x6007('0x1a')]?_0x10dc13[_0x6007('0x1a')][_0x6007('0x1c')]||null:null,'attributes':_0x10dc13['options']?_0x10dc13[_0x6007('0x1a')][_0x6007('0x1d')]||null:null,'include':_0x10dc13[_0x6007('0x1a')]?_0x10dc13['options']['include']?_[_0x6007('0x1e')](_0x10dc13[_0x6007('0x1a')][_0x6007('0x1f')],function(_0x60a9c2){return{'model':db[_0x60a9c2[_0x6007('0x20')]],'as':_0x60a9c2['as'],'attributes':_0x60a9c2['attributes'],'include':_0x60a9c2[_0x6007('0x1f')]?_['map'](_0x60a9c2[_0x6007('0x1f')],function(_0x3d37e7){return{'model':db[_0x3d37e7[_0x6007('0x20')]],'as':_0x3d37e7['as'],'attributes':_0x3d37e7[_0x6007('0x1d')],'include':_0x3d37e7[_0x6007('0x1f')]?_['map'](_0x3d37e7['include'],function(_0x8e9fc4){return{'model':db[_0x8e9fc4['model']],'as':_0x8e9fc4['as'],'attributes':_0x8e9fc4[_0x6007('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x13a163){logger['info'](_0x6007('0x18'),_0x10dc13);logger['debug'](_0x6007('0x18'),_0x10dc13,JSON[_0x6007('0x13')](_0x13a163));_0x4cf4ff(_0x13a163);})[_0x6007('0x21')](function(_0x3c0183){logger['error'](_0x6007('0x18'),_0x3c0183[_0x6007('0x16')],_0x10dc13);_0x355566(_0x4d0ea1[_0x6007('0x14')](0x1f4,_0x3c0183[_0x6007('0x16')]));});});};