Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / setting / setting.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 _0x1b0b=['util','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Setting,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','ShowSetting','Setting','options','raw','attributes','include','map','model','debug','catch','lodash'];(function(_0x4b2436,_0x452299){var _0x4f5ab2=function(_0x5c6679){while(--_0x5c6679){_0x4b2436['push'](_0x4b2436['shift']());}};_0x4f5ab2(++_0x452299);}(_0x1b0b,0x77));var _0xb1b0=function(_0x209941,_0x5c9988){_0x209941=_0x209941-0x0;var _0x1e8729=_0x1b0b[_0x209941];return _0x1e8729;};'use strict';var _=require(_0xb1b0('0x0'));var util=require(_0xb1b0('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xb1b0('0x2'));var fs=require('fs');var Redis=require(_0xb1b0('0x3'));var db=require(_0xb1b0('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xb1b0('0x5'))(_0xb1b0('0x6'));var config=require(_0xb1b0('0x7'));var jayson=require(_0xb1b0('0x8'));var client=jayson[_0xb1b0('0x9')][_0xb1b0('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2c160e,_0x162c98,_0x93ccaf){return new BPromise(function(_0x261353,_0x211a65){return client[_0xb1b0('0xb')](_0x2c160e,_0x93ccaf)[_0xb1b0('0xc')](function(_0x1fcd5a){logger[_0xb1b0('0xd')](_0xb1b0('0xe'),_0x162c98,_0xb1b0('0xf'));logger['debug']('Setting,\x20%s,\x20%s,\x20%s',_0x162c98,'request\x20sent',JSON[_0xb1b0('0x10')](_0x1fcd5a));if(_0x1fcd5a[_0xb1b0('0x11')]){if(_0x1fcd5a[_0xb1b0('0x11')]['code']===0x1f4){logger[_0xb1b0('0x11')](_0xb1b0('0xe'),_0x162c98,_0x1fcd5a[_0xb1b0('0x11')][_0xb1b0('0x12')]);return _0x211a65(_0x1fcd5a[_0xb1b0('0x11')][_0xb1b0('0x12')]);}logger['error'](_0xb1b0('0xe'),_0x162c98,_0x1fcd5a[_0xb1b0('0x11')][_0xb1b0('0x12')]);return _0x261353(_0x1fcd5a[_0xb1b0('0x11')]['message']);}else{logger[_0xb1b0('0xd')]('Setting,\x20%s,\x20%s',_0x162c98,'request\x20sent');_0x261353(_0x1fcd5a[_0xb1b0('0x13')][_0xb1b0('0x12')]);}})['catch'](function(_0x2f8f50){logger['error'](_0xb1b0('0xe'),_0x162c98,_0x2f8f50);_0x211a65(_0x2f8f50);});});}exports[_0xb1b0('0x14')]=function(_0x2f0db7){var _0x358fb0=this;return new Promise(function(_0x29409d,_0x590e3e){return db[_0xb1b0('0x15')]['find']({'raw':_0x2f0db7[_0xb1b0('0x16')]?_0x2f0db7['options'][_0xb1b0('0x17')]===undefined?!![]:![]:!![],'where':_0x2f0db7[_0xb1b0('0x16')]?_0x2f0db7[_0xb1b0('0x16')]['where']||null:null,'attributes':_0x2f0db7['options']?_0x2f0db7['options'][_0xb1b0('0x18')]||null:null,'include':_0x2f0db7['options']?_0x2f0db7[_0xb1b0('0x16')][_0xb1b0('0x19')]?_[_0xb1b0('0x1a')](_0x2f0db7[_0xb1b0('0x16')][_0xb1b0('0x19')],function(_0x201829){return{'model':db[_0x201829[_0xb1b0('0x1b')]],'as':_0x201829['as'],'attributes':_0x201829[_0xb1b0('0x18')],'include':_0x201829[_0xb1b0('0x19')]?_[_0xb1b0('0x1a')](_0x201829[_0xb1b0('0x19')],function(_0x2d5c3c){return{'model':db[_0x2d5c3c['model']],'as':_0x2d5c3c['as'],'attributes':_0x2d5c3c[_0xb1b0('0x18')],'include':_0x2d5c3c['include']?_['map'](_0x2d5c3c['include'],function(_0x566046){return{'model':db[_0x566046['model']],'as':_0x566046['as'],'attributes':_0x566046[_0xb1b0('0x18')]};}):[]};}):[]};}):[]:[]})[_0xb1b0('0xc')](function(_0x35f81b){logger[_0xb1b0('0xd')](_0xb1b0('0x14'),_0x2f0db7);logger[_0xb1b0('0x1c')]('ShowSetting',_0x2f0db7,JSON[_0xb1b0('0x10')](_0x35f81b));_0x29409d(_0x35f81b);})[_0xb1b0('0x1d')](function(_0x46e70e){logger[_0xb1b0('0x11')](_0xb1b0('0x14'),_0x46e70e[_0xb1b0('0x12')],_0x2f0db7);_0x590e3e(_0x358fb0[_0xb1b0('0x11')](0x1f4,_0x46e70e[_0xb1b0('0x12')]));});});};