6537c63f4ae7fec3bfa39ce466e6014657230b67
[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 _0xdc31=['result','catch','Setting','find','options','raw','attributes','map','include','model','ShowSetting','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','client','http','request','then','info','Setting,\x20%s,\x20%s','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x1c4606,_0x295858){var _0x3cc7fd=function(_0x20fae5){while(--_0x20fae5){_0x1c4606['push'](_0x1c4606['shift']());}};_0x3cc7fd(++_0x295858);}(_0xdc31,0x10b));var _0x1dc3=function(_0x461f24,_0x71affe){_0x461f24=_0x461f24-0x0;var _0x35f2e0=_0xdc31[_0x461f24];return _0x35f2e0;};'use strict';var _=require(_0x1dc3('0x0'));var util=require(_0x1dc3('0x1'));var moment=require(_0x1dc3('0x2'));var BPromise=require(_0x1dc3('0x3'));var rs=require(_0x1dc3('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x1dc3('0x5'));var logger=require(_0x1dc3('0x6'))(_0x1dc3('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x1dc3('0x8')][_0x1dc3('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xb31082,_0x440b1d,_0x5e096b){return new BPromise(function(_0x5c96da,_0x211c13){return client[_0x1dc3('0xa')](_0xb31082,_0x5e096b)[_0x1dc3('0xb')](function(_0x291f94){logger[_0x1dc3('0xc')](_0x1dc3('0xd'),_0x440b1d,_0x1dc3('0xe'));logger[_0x1dc3('0xf')](_0x1dc3('0x10'),_0x440b1d,'request\x20sent',JSON[_0x1dc3('0x11')](_0x291f94));if(_0x291f94[_0x1dc3('0x12')]){if(_0x291f94[_0x1dc3('0x12')][_0x1dc3('0x13')]===0x1f4){logger[_0x1dc3('0x12')]('Setting,\x20%s,\x20%s',_0x440b1d,_0x291f94['error'][_0x1dc3('0x14')]);return _0x211c13(_0x291f94[_0x1dc3('0x12')][_0x1dc3('0x14')]);}logger[_0x1dc3('0x12')](_0x1dc3('0xd'),_0x440b1d,_0x291f94['error'][_0x1dc3('0x14')]);return _0x5c96da(_0x291f94['error'][_0x1dc3('0x14')]);}else{logger[_0x1dc3('0xc')]('Setting,\x20%s,\x20%s',_0x440b1d,'request\x20sent');_0x5c96da(_0x291f94[_0x1dc3('0x15')][_0x1dc3('0x14')]);}})[_0x1dc3('0x16')](function(_0x5ea281){logger[_0x1dc3('0x12')](_0x1dc3('0xd'),_0x440b1d,_0x5ea281);_0x211c13(_0x5ea281);});});}exports['ShowSetting']=function(_0x15fbc0){var _0x18c4f3=this;return new Promise(function(_0x4c8192,_0x1fb575){return db[_0x1dc3('0x17')][_0x1dc3('0x18')]({'raw':_0x15fbc0['options']?_0x15fbc0[_0x1dc3('0x19')][_0x1dc3('0x1a')]===undefined?!![]:![]:!![],'where':_0x15fbc0[_0x1dc3('0x19')]?_0x15fbc0[_0x1dc3('0x19')]['where']||null:null,'attributes':_0x15fbc0[_0x1dc3('0x19')]?_0x15fbc0[_0x1dc3('0x19')][_0x1dc3('0x1b')]||null:null,'include':_0x15fbc0['options']?_0x15fbc0[_0x1dc3('0x19')]['include']?_[_0x1dc3('0x1c')](_0x15fbc0['options'][_0x1dc3('0x1d')],function(_0x39c453){return{'model':db[_0x39c453[_0x1dc3('0x1e')]],'as':_0x39c453['as'],'attributes':_0x39c453[_0x1dc3('0x1b')],'include':_0x39c453['include']?_['map'](_0x39c453['include'],function(_0x5742ea){return{'model':db[_0x5742ea[_0x1dc3('0x1e')]],'as':_0x5742ea['as'],'attributes':_0x5742ea[_0x1dc3('0x1b')],'include':_0x5742ea[_0x1dc3('0x1d')]?_[_0x1dc3('0x1c')](_0x5742ea['include'],function(_0x472364){return{'model':db[_0x472364[_0x1dc3('0x1e')]],'as':_0x472364['as'],'attributes':_0x472364['attributes']};}):[]};}):[]};}):[]:[]})[_0x1dc3('0xb')](function(_0x5625ce){logger[_0x1dc3('0xc')](_0x1dc3('0x1f'),_0x15fbc0);logger[_0x1dc3('0xf')](_0x1dc3('0x1f'),_0x15fbc0,JSON[_0x1dc3('0x11')](_0x5625ce));_0x4c8192(_0x5625ce);})[_0x1dc3('0x16')](function(_0x22e2ea){logger['error'](_0x1dc3('0x1f'),_0x22e2ea[_0x1dc3('0x14')],_0x15fbc0);_0x1fb575(_0x18c4f3['error'](0x1f4,_0x22e2ea[_0x1dc3('0x14')]));});});};